In this example I want the led to come on when the number is > 20, but it comes on in reverse. If I flip the sign it does what I want, but I would rather the code be correct than have a work around for the result I want. Any suggestions?
I'm using the lilypad protosnap. There led is on pin #9. The red comes on all the way up to 20 and at 20 goes off. If I change the ">" to "<" it gives the the desired output.
Here's the full code:
int ledRed = 9;
void setup()
{
Serial.begin(9600); // send and receive at 9600 baud
pinMode(ledRed, OUTPUT);
}
int number = 0;
void loop()
{
Serial.print("The number is ");
Serial.println(number); // print the number
delay(1000); // delay half second between numbers
number++; // to the next number
You need to build a simple script that does nothing more than set the LED pin HIGH. Does the LED come on, then, or go off? It sounds like you have the LED wired wrong.