Coding the first program in Tinkercad Circuits
The First Program
Create a circuit and attach an LED to pin 7 on the Arduino board
Copy the text below into the Code Text section.
* Writing after the // is irrelevant to the function of the code and is for clarification and annotation only.
**Terms are case sensitive. Using upper or lower case incorrectly, or misspelling a work, will cause a syntax error.
_________________________________________________________________________
//Pin 7 needs to have an LED attached to it
//Give "7" a name - in this case, led
int led = 7;
//the setup routine runs once when you press reset
void setup() {
//initialise the digital pin as an output - pins
//by default are inputs
pinMode(led,OUTPUT);
}
//the loop routine runs over and over again forever
void loop() {
digitalWrite(led, HIGH); //turn the LED on (HIGH is the voltage level)
delay(1000); //wait for one second
digitalWrite(led, LOW); //turn the LED off by making the voltage LOW)
delay(1000); //wait for one second
}
_________________________________________________________________________
Your screen should now look something like the picture below
Extension Tasks - Once you have your code working try and make the following changes.
Can you change the code to make the LED flash faster?
Can you make it flash slower?
Can you add another LED?
Can you make them flash alternatively?