Content-Length: 3105665 | pFad | https://www.scribd.com/document/489824099/arduino-to-proteus-simulation-pdf

0 Arduino To Proteus Simulation PDF | PDF | Arduino | Ultrasound
0% found this document useful (0 votes)
152 views12 pages

Arduino To Proteus Simulation PDF

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 12

Eng.

mohammed Albhaisi

Lab#3 : arduino to proteus simulation

for simulate Arduino program that you wrote you have to have these programs :

1-Arduino C

2-proteus

3- Virtual Serial Port Driver

4-Arduino library to proteus

You must do following Steps if you want to simulate your program:

1-We must make virtual port using Virtual Serial Port Driver

Here we make virtual port between COM1 and COM2

2- choose port and Arduino type from tools

Hints : Here we connected arduino to COM 1


Eng.mohammed Albhaisi

3-write your code , then write code to initialize serial communication (you may need it
sometimes )

void setup()
{
//initialize serial communications at a 9600 baud rate
Serial.begin(9600);
}
4-after you finish your code , then choose from Sketch > Export compiled Binary to get hex file .

5- choose Arduino uno from protues ,then connect COMPIM(serial port) to arduino Rx from
Arduino to Rx in COMPIM and vice versa ,then choose port COM2 in COMPIM ,and change baud
rate to 9600 (or try 115200 )
Eng.mohammed Albhaisi

Hints : here we choose COM 2 because we connect arduino to COM 1

6-upload hex file to arduino that you export it in step number four .
Eng.mohammed Albhaisi

Example # 1 : lm 35 sensor
First code Arduino C :

const int sensorPin=A0;


int reading;
float voltage;
float temperatureC;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
reading=analogRead(sensorPin);
voltage=reading*5.0/1024;
Serial.print(voltage);
Serial.println("volts");
temperatureC=(voltage -0.5)*100;
Serial.println("Temperature is:'");
Serial.print(temperatureC);
Serial.println("degrees C");
delay(1000);
}
Second connect your circuit at proteus program as following :
Eng.mohammed Albhaisi

Example # 2 : PWM

Arduino C :

Second proteus :
Eng.mohammed Albhaisi

Example # 3 : Servo motor

Arduino C :

Second proteus :
Eng.mohammed Albhaisi

Example # 4 : Ultra sonic

HC-SR04 ultrasonic ranging module.


HC-SR04 is the ultrasonic ranging module used here. HC-SR04 consists of an ultrasonic
transmitter, receiver and necessary electronics for making it a stand alone system. The
operating principle is very simple. It sends 8 pulses of 40KHz sound waves, and picks up the
reflected wave. The time lag between the transmission and reception is measured and the
distance is calculated from the equation D=TS/2. Where D is the distance, T is the time lag
and S is the speed of sound. The output of the HC-SR04 will be a pulse whose width is
proportional to the distance. From the datasheet, width of the output signal will be 58uS for a
distance of 1cm. What we need to do is to just send a 10uS wide trigger signal to the trigger
pin of the module and wait for the output pulse at the echo pin of the module. Timing diagram
and pin out of the ultrasonic module is given below.
Eng.mohammed Albhaisi

Arduino C :

const int pingPin = 7; // Trigger Pin of Ultrasonic Sensor


const int echoPin = 6; // Echo Pin of Ultrasonic Sensor
void setup()
{
Serial.begin(9600); // Starting Serial Terminal
}
void loop()
{
long duration, inches, cm;
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(10);
digitalWrite(pingPin, LOW);
pinMode(echoPin, INPUT);
duration = pulseIn(echoPin, HIGH);
inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
delay(100);
}
long microsecondsToInches(long microseconds)
{
return microseconds / 74 / 2;
}
long microsecondsToCentimeters(long microseconds)
{
return microseconds / 29 / 2;
}
Eng.mohammed Albhaisi

Second proteus :
Eng.mohammed Albhaisi

Example # 5 :LCD to arduino


To get more information go to example as shown :

Arduino C :

// include the library code:


#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
lcd.setCursor(0,1) ;
lcd.print("DSP lab ! ");
}
void loop() {
// Turn off the display:
lcd.noDisplay();
delay(500);
// Turn on the display:
lcd.display();
delay(500);
}
Eng.mohammed Albhaisi

Second proteus :
Eng.mohammed Albhaisi

Exercise :

1- Do all example in your report (arduino C and proteus )


2- Simulate code that make Traffic Light (red , yellow, green)

You might also like









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://www.scribd.com/document/489824099/arduino-to-proteus-simulation-pdf

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy