Assignment 2: Simulate a Sensor to control an alarm
Before you attempt this assignment, it is suggested you understand circuits (and the Arduino code) 1B and 1C.
Sensor
That being said, in this assignment, we’ll be mimicking an Infrared Sensor (detects objects) by utilizing the potentiometer. The potentiometer will provide us voltage potential that we can vary from 0V to 5V (similar to 1B). This voltage potential represents the output of a sensor. Assume the sensor cannot detect anything beyond 10 yards. So, if an object is in front of the sensor at 5 yards out, the output of the sensor should be 2.5 volts. At 0 yards out, the sensor output should be approximately 5 volts.
Now that you’ve established your sensor, it will be your job to utilize this sensor to trip a visual alarm system.
Visual Alarm
Imagine this microcontroller unit is on a vehicle operated by a person. You are designing a visual alarm system that will alert the driver if the vehicle approaches an object.
You are tasked to do this.
A Solid Green LED is on when no object is detected by the sensor (red, yellow, and blue LEDs remain off).
A flashing Yellow LED when the vehicle approaches an object (green, red, and blue LEDs remain off).
Alternating Blue and Red flashing LEDs when the vehicle is close to an object (green and yellow LEDs remain off.
What you’ll turn in
You’ll upload your Arduino code and your schematic in a single file. The schematic can be handrawn or you may use a CAD program to draw your schematic. Keep in mind, your schematic should be detailed enough so somebody can build your design. What I mean by this is, label your inputs, outputs, sensors, etc. (A0, A1, GND, 5V, 1, 2, etc.).
Tip
Understand the code of 1B and 1C. Additionally, research how to implement “if statements” in Arduino. There are numerous sources and examples online on how to properly use “if statements.” You’ll most likely need “if statements” to complete this assignment.
int sensorPin = A0; // select the input pin for the sensor
(potentiometer)
int greenLed = 12; // select the pin for the green LED
int redLed = 11; // select the pin for the green LED
int yellowLed = 10; // select the pin for the green LED
int blueLed = 9; // select the pin for the green LED
int sensorValue = 0; // variable to store the value coming from the
sensor
void setup() {
// declare the four led pins as OUTPUT:
pinMode(greenLed, OUTPUT);
pinMode(redLed, OUTPUT);
pinMode(yellowLed, OUTPUT);
pinMode(blueLed, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
sensorValue = analogRead(sensorPin); // read the raw data coming in
on analog pin 0
float voltage = sensorValue * (5.0 / 1024.0); // Convert the raw
data value (0 - 1023) to voltage (0.0V - 5.0V)
//If no objetct detected (object is beyond 10 yard distance),
then voltage will be zero.
if (voltage == 0) {
digitalWrite(greenLed, HIGH);
digitalWrite(redLed, LOW);
digitalWrite(yellowLed, LOW);
digitalWrite(blueLed, LOW);
}
// If objetct is within 10 yard distance, voltage will be greater
than zero.
else {
// When the voltage is less than 4V, the distance will be greater
than 2 yards.
while ((voltage < 4)&&(voltage>0)) {
digitalWrite(greenLed, LOW);
digitalWrite(redLed, LOW);
digitalWrite(blueLed, LOW);
digitalWrite(yellowLed, HIGH);
delay (1000);
digitalWrite(yellowLed, LOW);
}
// When the voltage is more than 4V, the distance will be less than
2 yards.
// This distance is considered as close object. You can change the
value according to the requirement.
while (voltage > 4){
digitalWrite(greenLed, LOW);
digitalWrite(yellowLed, LOW);
digitalWrite(blueLed, LOW);
digitalWrite(redLed, HIGH);
delay (1000);
digitalWrite(blueLed, HIGH);
digitalWrite(redLed, LOW);
}
}
}
Assignment 2: Simulate a Sensor to control an alarm Before you attempt this assignment, it is...
Simulate a Sensor to control an alarm Before you attempt this assignment, it is suggested you understand circuits (and the Arduino code) 1B and 1C. Sensor That being said, in this assignment, we’ll be mimicking an Infrared Sensor (detects objects) by utilizing the potentiometer. The potentiometer will provide us voltage potential that we can vary from 0V to 5V (similar to 1B). This voltage potential represents the output of a sensor. Assume the sensor cannot detect anything beyond 10 yards....
MICROCONTROLLERS (Arduino Uno) Submit a schematic drawing and source code: Operating a simple DC motor with a Potentiometer Minimum 3 speeds; fast, slow, stop (0/mph) At fast, green LED on At slow, yellow LED on At stop, red & blue LEDs alternating on/off Thank you in advance
EECP3171 - Assignment Sem-3 (2018-19) Submission method: Individual Demonstration of Simulation on Tinkercad Demonstration Schedule: 20 June - Thursday 9:00 till 1:00 PM in CE111 (my office) Note: Any student who will come after deadline will be marked zero. Problem Statement Develop a simulation of a Electronic Thermometer using Tinkercad. The LCD will display the temperature in Celsius and Fahrenheit. Red LED will be ON if temperature is> 50 C and Green will be ON if temperature is < 50...