Last active
December 20, 2021 16:40
-
-
Save Monmoy042/aee621b9801cbfcac7f56441fe628340 to your computer and use it in GitHub Desktop.
This gist is all about the coding of Arduino. From this gist anyone can learn how we can code an Arduino very easily. This gist will cove all the things that we need to know about the coding of Arduino.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int led = 13; | |
void setup() { | |
pinMode(led, OUTPUT); | |
} | |
void loop() { | |
digitalWrite(led, HIGH); | |
delay(1000); | |
digitalWrite(led, LOW); | |
delay(1000); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Integer Data Type | |
int num1 = 10; | |
const int num2 = 20; | |
// Float Data Type | |
const float pi = 3.1416; | |
// String Data Type | |
String myName = "John Doe"; | |
// Character Data Type | |
char firstLetter = 'A'; | |
// boolean data type | |
bool isBlink = false; | |
// Practical Use of Variable | |
int led = 13; | |
void setup() { | |
Serial.begin(9600); | |
pinMode(led,OUTPUT); | |
} | |
void loop() { | |
Serial.print("My first number is "); | |
Serial.println(num1); | |
Serial.print("My second number is "); | |
Serial.println(num2); | |
Serial.println(pi); | |
Serial.println("My name is " + myName); | |
Serial.print("My first Character is "); | |
Serial.println(firstLetter); | |
Serial.println(isBlink); | |
// Led ON | |
digitalWrite(led,HIGH); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int redLed = 5; | |
const int buttonPin = 7; | |
int buttonStatus; | |
int greenLed = A0; | |
int potPin = A2; | |
float potValue; | |
void setup() { | |
// Set the pinMode(INPUT or OUTPUT) | |
pinMode(redLed,OUTPUT); | |
pinMode(buttonPin,INPUT); | |
pinMode(greenLed,OUTPUT); | |
pinMode(potPin,INPUT); | |
Serial.begin(9600); | |
} | |
void loop() { | |
// Digital Write | |
digitalWrite(redLed,HIGH); | |
Serial.print("RED Led ON :"); | |
Serial.println(redLed); | |
delay(1000); | |
digitalWrite(redLed,LOW); | |
Serial.print("RED Led OFF :"); | |
Serial.println(redLed); | |
delay(1000); | |
// Digital Read | |
buttonStatus = digitalRead(buttonPin); | |
Serial.print("The Button Status is: "); | |
Serial.println(buttonStatus); | |
// Analog Write | |
analogWrite(greenLed,255); | |
delay(2000); | |
analogWrite(greenLed,0); | |
delay(2000); | |
// Analog Read | |
//Serial.println(potPin); | |
potValue = analogRead(potPin); | |
Serial.print("The pot value is: "); | |
Serial.println(potValue); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int ledPin = 5; | |
void setup(){ | |
pinMode(ledPin,OUTPUT); | |
Serial.begin(9600); | |
} | |
void loop(){ | |
digitalWrite(ledPin,HIGH); | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment