Galera, boa tarde... sou novo aqui e gostaria da ajuda de vocês.

Estou com um projeto na faculdade e estou usando o arduino, php e mysql no projeto.

para fazer a ligação do php para o arduino eu utilizei esse tutorial: https://www.lassiemarlowe.com/tutorials/power-led-bulbs-arduino-php...

Funcionou perfeitamente, mas agora eu quero digitar um texto na tela do php e ele aparecer no LCD, mas não estou conseguindo.

Por exemplo, quando eu apertar o botão 1 ligar o primeiro led e no lcd aparecer o nome que foi digitado anteriormente.

Obrigado 

Exibições: 527

Responder esta

Respostas a este tópico

Não consigo abrir o link, sou só eu que não consigo?

Sugiro detalhar melhor para podermos ajudá-lo.

Boa sorte,

  'Eiju

Eu tenho esse código no arduino:

/*
Script by Lassie Marlowe Digital
by Paddy O'Sullivan
*/

// Assign each of our input pins to an integer variable
int LED_one = 13;
int LED_two = 12;
int LED_three = 11;
int LED_four = 10;

void setup() {
Serial.begin( 9600 );

pinMode( LED_one, OUTPUT );
pinMode( LED_two, OUTPUT );
pinMode( LED_three, OUTPUT );
pinMode( LED_four, OUTPUT );

} //END OF SETUP

void loop() {
//wait until the serial connection is open
while (Serial.available() == 0);

//read from the serial connection; the - '0' is to cast the values as the int and not the ASCII code
int COM_value = Serial.read() - '0';

//print to the console for testing
Serial.println(COM_value);

//LED #`1
if( COM_value == 1 )
{
digitalWrite( LED_one, HIGH ); // HIGH VOLTAGE - TURNED ON
}
if( COM_value == 2 )
{
digitalWrite( LED_one, LOW ); // LOW VOLTAGE - TURNED OFF
}

}

E esse no php:

<html>
<head>

<?php
// SPECIFY USB PORT TO USE
$usb_comPort = "COM4";

switch($_POST)
{
case isset($_POST['submitOn']):
exec("ECHO 1 > $usb_comPort"); // Turn On LED 1
break;
case isset($_POST['submitOff']):
exec("ECHO 2 > $usb_comPort "); // Turn Off LED 1
break;
}

?>
</head>

<body>

<h1>Control Panel</h1>

<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<input type='submit' name='submitOn' value='Turn LED 1 ON'>
<input type='submit' name='submitOff' value='Turn LED 1 OFF'>

</form>

</body>

</html>

Quando eu aperto o botao 1 o led acende, e o botao 2 o led apaga, eu quero que alem do led aceder tbm envie um texto para o LCD, mas não um texto fixo, um texo que eu coloque em algum campo antes de apertar o botão pro led acender...

nao sei se expliquei bem...

no php dá para incluir um campo texto:

Ente o texto aqui: <input type=''text' name='nomedomeutexto'>

Sugestão:

Eu prefiro separar o botão submit para funcionar apenas como submit a não ser que prefira que funcione apenas com um só click. O código ficaria assim:

<input type='checkbox' name='Leds' value='Led 1'> Led 1 <br>

<input type='checkbox' name='Leds' value='Led 2'> Led 2 <br>

<input type='checkbox' name='Leds' value='Led 3'> Led 3 <br>

<input type='checkbox' name='Leds' value='Led 4'> Led 4 <br>

<input type='submit' name='submit' value='Enviar'>

Espero que funcione, não manjo muito de php mas este pedaço é HTML.

Boa sorte,

  'Eiju

RSS

© 2024   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço