Skip to content

Instantly share code, notes, and snippets.

View iotguider's full-sized avatar

Iotguider iotguider

View GitHub Profile
@iotguider
iotguider / LED_with_Pushbutton_in_Arduino.ino
Created July 25, 2017 15:29
Code for LED with Pushbutton in Arduino
const int buttonPin = 6; //Number of Pushbutton Pin
const int ledPin = 13; //Number of LED Pin
int buttonState = 0; //Variable of Pushbutton Status
void setup() {
//Initialize LED Pin
pinMode(ledPin, OUTPUT);
//Initialize Pushbutton Pin
pinMode(buttonPin, INPUT);
@iotguider
iotguider / Temperature_Sensor_in_Arduino.ino
Created July 25, 2017 15:31
Code for Temperature Sensor in Arduino
int tempPin = A0; //Number of Temperature Sensor Pin
int analoginput; //Variable to store Analog Input Value
float temp; //Variable to store Temperature in C
void setup()
{
// Begin the Serial Monitor at 9600 Baud
Serial.begin(9600);
}
@iotguider
iotguider / Ultrasonic_Sensor_in_Arduino.ino
Created July 25, 2017 15:31
Code for Ultrasonic Sensor HC-SR04 in Arduino
#define trigPin 13
#define echoPin 12
void setup() {
Serial.begin (9600); // Begin the Serial Monitor at 9600 Baud
pinMode(trigPin, OUTPUT); // Initialize Trigger Pin
pinMode(echoPin, INPUT); // Initialize Echo Pin
}
void loop() {
@iotguider
iotguider / Interfacing_LCD_in_Arduino.ino
Last active July 27, 2017 12:16
Code for Interfacing 16x2 LCD in Arduino
#include <LiquidCrystal.h> //Library for LCD
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //initialize the library with the numbers of the interface pins
//The function parameter is as follows LiquidCrystal(rs, enable, d4, d5, d6, d7)
void setup() {
lcd.begin(16, 2); //Setup number of rows andcolumns of LCD
}
void loop() {
@iotguider
iotguider / Interfacing_LDR_in_Arduino.ino
Last active August 4, 2017 16:34
Code for Interfacing LDR in Arduino
#define LDR A0 //Initialize LDR sensor pin.
void setup() {
//Begin the Serial Monitor at 9600 Baud
Serial.begin(9600);
}
void loop() {
int value = analogRead(LDR); //Store sensor value to variable
Serial.println(value); //Print the value to serial
@iotguider
iotguider / H-Bridge_Motor_Driver_in_Arduino.ino
Last active March 16, 2018 10:37
Code for H-Bridge Motor Driver in Arduino
int input1 = 11; //Number of Motor Input 1 Pin
int input2 = 9; //Number of Motor Input 2 Pin
void setup() {
pinMode(input1, OUTPUT); //Initialize Input 1 Pin
pinMode(input2, OUTPUT); //Initialize Input 2 Pin
}
void loop() {
analogWrite(input1, 0); //Write Analog value to Input 1
@iotguider
iotguider / Blink_LED_for_ESP8266.ino
Last active February 8, 2019 09:26
Code for Blink LED for ESP8266
@iotguider
iotguider / Serial_communication_sender_Arduino.ino
Last active May 18, 2018 12:30
Code for Serial communication sender Arduino
char mystr[5] = "Hello"; //String data
void setup() {
// Begin the Serial at 9600 Baud
Serial.begin(9600);
}
void loop() {
Serial.write(mystr,5); //Write the serial data
delay(1000);
@iotguider
iotguider / Serial_communication_receiver_Arduino.ino
Last active May 19, 2018 09:03
Code for Serial communication receiver Arduino
char mystr[10]; //Initialized variable to store recieved data
void setup() {
// Begin the Serial at 9600 Baud
Serial.begin(9600);
}
void loop() {
Serial.readBytes(mystr,5); //Read the serial data and store in var
Serial.println(mystr); //Print data on Serial Monitor
@iotguider
iotguider / Create_web_server_with_ESP8266_NodeMCU.ino
Last active June 11, 2019 13:13
Code for Creating web server with ESP8266/NodeMCU
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
ESP8266WebServer server(80);
const char* ssid = "WiFi_SSID"; //Enter Wi-Fi SSID
const char* password = "WiFi_Password"; //Enter Wi-Fi Password
void setup() {
Serial.begin(115200); //Begin Serial at 115200 Baud