
The variable "button" was assigned the value of 3 (which will later be linked to pin 3 on the hardware), while the variable "LED" was assigned the value of 7. One was called "LED" and one was called "button". In the above examples, 2 variables, both of int type (integers - that is, whole numbers) were defined.

Think of these lines (anything before the "void setup()" on line 4 above) as a bit of a dictionary. Once uploaded, the LED should illuminate when the button is pressed, and stop illuminating when the button is released. Once it has been verified with no errors, upload the sketch using the Upload button (arrow icon).The sketch will need to be saved before it will be verified - simply save this to the computer or a USB if you wish to keep this code. Click the Verify button (the tick icon, top left), and ensure there are no errors.Connect one LED to Pin 7, and one push button to Pin 3 on the board.Int buttonState = digitalRead(button) //read the status of the buttonĭigitalWrite(LED,HIGH) //apply high voltage to LEDĭigitalWrite(LED,LOW) //apply low voltage to LED PinMode(LED, OUTPUT) //define LED an OUTPUT device PinMode(button, INPUT) //define button an INPUT device Int LED = 7 //attach an LED to digital pin 7 Int button = 3 //attach a button to digital pin 3

If you have done this successfully, you will notice that keywords will change colour.
Arduino not equal symbol software#

