This is the basic code that everyone learns as their first arduino project
The blinking LED
It uses the delay function.
This function is good for many cases, however it has a disadvantage that it can slow up the program.
However, for this sketch, its perfect.
The setup:
The cathode (short leg) of the LED connects to GND
The resistor is 220 Ohm
The anode connects to pin 7 in this case.
Here is the basic Code
void setup() {
// put your setup code here, to run once:
pinMode(7, OUTPUT); // configure the pin as an output
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(7, HIGH); // turn LED on
delay(1000); // wait 1 second
digitalWrite(7, LOW); // turn LED off
delay(1000); // wait one second
}
---------------------------------
-------------------------------------
No comments:
Post a Comment