Guys, I'm still experimenting with arduino and make this sketch to light an led when l is pressed( and released) and then switch off when it is pressed again. On the arduino simulator it works as intended but when I use the arduino nothing happens pls help asap
Thanks in advance
This is the program : int ledPin = 13;
boolean ledState = LOW;
void setup()
{
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
}
void loop()
{
digitalWrite(ledPin, ledState);
int key;
if (Serial.available() >0)
{
boolean ledState = LOW;Â // <----- first variable
...
    if (ledState == HIGH)
    {
     boolean ledState = LOW;  // <----- second variable
     digitalWrite(ledPin, ledState);
     Serial.println("LED is Off");
    }
    else
    {
     boolean ledState = HIGH;  // <----- third variable
You have three ledState variables there, not one.
Leave "boolean" off the second two. That is declaring a new variable, not assigning to an existing one.
Yes that one was also a mistake that I made when the sketch was not working because I though that was the reason of the sketch not working as intended, and after I tried it with no result I forgot to arrange the changes.
Thanks for the interest but I wrote the function of the sketch in the title so I will know what 108 stand for, but I will take your advice better safe than sorry.
jusspit:
Thanks for the interest but I wrote the function of the sketch in the title so I will know what 108 stand for, but I will take your advice better safe than sorry.
So your instructions tell you to press the key corresponding to 108 on the keyboard, is that it? Try to think ahead a few years.
I think what's worrying is that an Arduino 'simulator' (emulator?) costs more than an actual Arduino...!??
The list price for Simulator for Arduino will be around $50 for v1.00. For the pre-release stage, the Pro version is available at a discount which will be increased gradually as milestones are reached, and a discount renewal is available when the support period page expires. This rewards early adopters.
jusspit:
I chosen l for lights and my program was made so that to see if I can apply the same concept for a bigger project but thanks for your interest
Yeah, I had to lookup "ASCII character 108" to find it is lower case "L"
Figured it probably stood for "LED" or "Light" or maybe "Let it work, please!"