Huzzah!
It’s time to write your first code on arduino!
Please do ask if you have any problems regarding anything(well except the purpose of life).
Download it by clicking the following links
Arduino Blink Program Pdf
Arduino Blink Program Pptx
Here is the code
* Blinking program Turns on an LED on for two second, then off for one second, repeatedly. Er. Sahil khanna https://www.sahilkhanna.org/blog */ // Pin 8 has an LED connected // give it a name: int led = 8; // Button is connected to Pin 2 int button = 2; // Declare some variables. We'll see what we gonna do to them, later. int val=1; int check=0; // the setup routine runs once when you press reset: void setup() { Serial.begin(9600); // initialize the digital button pin as an input. pinMode(button, INPUT); // initialize the digital led pin as an output. pinMode(led, OUTPUT); } void blink() { digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(200); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(200); // wait for a second } // the loop routine runs over and over again forever: void loop(){ val=digitalRead(button); //reading values from button and saving it in the val variable. if(val==0){ check=~check; //if button is pressed then compliment the value of check. delay(500); } if(check==-1) blink(); // blink only if the value of check is one. }
Comments
You must log in to post a comment.