simple arduino coding
copy codes and upload in arduino IDE that's all
coding:
coding for ultrasonic sensor
#define trig 5
#define echo 6
void setup() {
Serial.begin(9600);
pinMode(trig,OUTPUT);
pinMode(echo,INPUT);
pinMode(13,OUTPUT);
}
void loop() {
long duration , distance;
digitalWrite(trig,LOW);
delay(2);
digitalWrite(trig,HIGH);
delay(2);
digitalWrite(trig,LOW);
duration= pulseIn(echo,HIGH);
distance=(duration/2)/29.1;
if(distance <= 10)
{
digitalWrite(13,HIGH);
}
else
{
digitalWrite(13,LOW);
}
delay(1000);
}
---------------------------***********----------------------------***************------------------
This is the codings for ultrasonic sensor...
For reference visit my youtube channel..
youtube video ultrasonic sensor video part1
void setup() {pinMode(13,OUTPUT);
pinMode(12,OUTPUT);
pinMode(11,OUTPUT);
pinMode(10,OUTPUT);
Serial.begin(9600);
}
void loop() {
digitalWrite(13,HIGH);
Serial.println("channl 1 is on");
delay(1000);
digitalWrite(13,LOW);
digitalWrite(12,HIGH);
Serial.println("channl 2 is on");
delay(1000);
digitalWrite(12,LOW);
digitalWrite(11,HIGH);
Serial.println("channl 3 is on");
delay(1000);
digitalWrite(11,LOW);
digitalWrite(10,HIGH);
Serial.println("channl 4 is on");
delay(1000);
digitalWrite(10,LOW);
}
---------------------------***********----------------------------***************------------------
This is the codings for relay...
For reference visitmy youtube channel..
void setup() {
pinMode(13,OUTPUT);
Serial.begin(9600);
}
void loop() {
if(Serial.available()>0)
{
int val=Serial.read();
delay(20);
if(val=='1')
{
digitalWrite(13,HIGH);
delay(20);
}
if(val=='0')
{
digitalWrite(13,LOW);
delay(20);
}
}
}
---------------------------***********----------------------------***************------------------
this is the codings for bluetooth module(HC-06)...
For reference visitmy youtube channel..
youtube videos what is bluetooth
youtube videos for bluetooth programming
pinMode(13,OUTPUT);
Serial.begin(9600);
}
void loop() {
if(Serial.available()>0)
{
int val=Serial.read();
delay(20);
if(val=='1')
{
digitalWrite(13,HIGH);
delay(20);
}
if(val=='0')
{
digitalWrite(13,LOW);
delay(20);
}
}
}
---------------------------***********----------------------------***************------------------
this is the codings for bluetooth module(HC-06)...
For reference visitmy youtube channel..
youtube videos what is bluetooth
youtube videos for bluetooth programming
Comments
Post a Comment