Robotics using Arduino
onchipLEDonprogram:
void setup()
{
// put your setup code here, to run once:
pinMode(13, OUTPUT);
}
void loop()
{
// put your main code here, to run repeatedly:
digitalWrite(13,HIGH);
}
onchipLEDoffprogram
onboardLEDblink1secdelay
void setup() {
// put your setup code here, to run once:
pinMode(13, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(13,LOW);
delay(1000);
digitalWrite(13,HIGH);
delay(1000);
}
externalLEDON1secOFF2secdelay
void setup() {
// put your setup code here, to run once:
pinMode(2, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(2,LOW);
delay(2000);
digitalWrite(2,HIGH);
delay(1000);
}
external4LEDspattern
void setup() {
// put your setup code here, to run once:
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(2,HIGH);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
delay(500);
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
delay(500);
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,LOW);
delay(500);
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
delay(500);
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
delay(500);
}
LED s Pattern Using For loop:
int i,j;
void setup() {
// put your setup code here, to run once:
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
for(i=1; i++ ; i<=5)
{
digitalWrite(i,HIGH);
j = i*500;
delay(j);
}}
IRSensorandonchipled
void setup() {
// put your setup code here, to run once:
pinMode(6, INPUT);
pinMode(13, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int x = digitalRead(6);
if(x==1)
{
digitalWrite(13,HIGH);
}
else
{
digitalWrite(13,LOW);
}
}
Automatic Hand Sanitizer
int y;
void setup() {
// put your setup code here, to run once:
pinMode(6,OUTPUT);
pinMode(8,INPUT);
y=0;
}
void loop() {
// put your main code here, to run repeatedly:
int x = digitalRead(8);
digitalWrite(6,HIGH);
if (x==0 && y==0)
{
digitalWrite(6,LOW);
delay(100);
digitalWrite(6,HIGH);
y=1;
}
else if(x==1)
{
y=0;
digitalWrite(6,HIGH);
}
}
onedcmotorprogram(Clockwise Rotation)
void setup() {
// put your setup code here, to run once:
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(2,HIGH);
digitalWrite(3,LOW);
}
onedcmotorprogram(Anticlockwise direction)
void setup() {
// put your setup code here, to run once:
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(3,HIGH);
digitalWrite(2,LOW);
}
robotmovingfront
void setup() {
// put your setup code here, to run once:
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(2,HIGH);
digitalWrite(3,LOW);
digitalWrite(4,HIGH);
digitalWrite(5,LOW);
}
robotmovingback
void setup() {
// put your setup code here, to run once:
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(2,LOW);
digitalWrite(3,HIGH);
digitalWrite(4,LOW);
digitalWrite(5,HIGH);
}
oneirandrobot
void setup() {
// put your setup code here, to run once:
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6,INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int x = digitalRead(6);
if(x==1)
{
digitalWrite(2,HIGH);
digitalWrite(3,LOW);
digitalWrite(4,HIGH);
digitalWrite(5,LOW);
}
else
{
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
}
}
twoirandrobot
void setup() {
// put your setup code here, to run once:
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6,INPUT);
pinMode(7,INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int x = digitalRead(6);
int y = digitalRead(7);
if(x==1 & y==1)
{
digitalWrite(2,HIGH);
digitalWrite(3,LOW);
digitalWrite(4,HIGH);
digitalWrite(5,LOW);
}
else if(x==0 & y==1)
{
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,HIGH);
}
else if(x==1 & y==0)
{
digitalWrite(2,LOW);
digitalWrite(3,HIGH);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
}
else
{
digitalWrite(2,LOW);
digitalWrite(3,HIGH);
digitalWrite(4,LOW);
digitalWrite(5,HIGH);
}
}
To generate .hex file in Arduino IDE:
Step1: Click on File
Step2: Click on Preferences
Step3: Check the box compilation at show verbose output during.
Where .hex file get generated:
Step1: Compile the program in Arduino IDE.
Step2: In the Console Window you will get Location of .hex file generated.
How to add any Proteus Library to Proteus Software:
Step1: Download the Required Proteus Library
Step2: Extract the zip folder.
Step3: Copy .IDX and .LIB files.
Step4: Paste the two files at C:\Program Files (x86)\Labcenter Electronics\Proteus 7 Professional\LIBRARY
Arduino IDE:
Proteus Arduino Library:
Proteus Infrared Sensor Library:
https://www.theengineeringprojects.com/2018/07/infrared-sensor-library-for-proteus.htmlProteus Motor Driver Library: