Arduino I/O

Class: Technology, Arduino I/O

Hardware:

  • Arduino Uno R3
  • Breadboard
  • Micro Servo x 2
  • PIR Sensor
  • Blue LED
Software:

Challenges:

  • Create IO

Brainstorming

My initial  idea was to create an automatic door/window or anything that reacts to the movement of human or animal. As an input device I chose to use RIP Motion Sensor and as an output I used two servo motors.

Uploading and debugging

This assignment I approached with no use of electronics. I planned to test Tinkercad – Circuits platform and to find the limits of available “hardware” components. The platform – www.tinkercad.com – has a finite set of components available to play with (no water sensors, water or air pumps, and no other microcontrollers); however, most of the basics components, such as dc motors, leds, sonar can readily be used to run simulations.   Once I prepared the components and wired them, I uploaded the code (see below) to microcontroller. Click on the picture below to open the project link and run the simulation. As a result, microcontroller when receives the signal from a PIR about the presence of the human/animal activates  two servo motors, piezo buzzer and LED.
#include Servo.h
#define pirPin 8
int led = 13;
int sound = 12;
Servo motor;
Servo motor2;
void setup()
{
Serial.begin(9600);
pinMode(pirPin, INPUT);
pinMode(led, OUTPUT);
motor.attach(3);
motor2.attach(6);
}
void loop()
{
int pirVal = digitalRead(pirPin);
if (pirVal == HIGH)
{
digitalWrite(led, HIGH);
digitalWrite(sound, HIGH);
Serial.print("Something is moving");
motor.write(90);
motor2.write(90);
delay (100);
}
else
{
Serial.print("Searching for movement");
digitalWrite(led, LOW);
digitalWrite(sound, LOW);
motor.write(0);
motor2.write(0);
}
}

Result

Arduino I/O

 

Tags: , , , ,

Trackback from your site.

address: 20 Myasnitskaya ulitsa
(metro stations ‘Lubyanka’ and ‘Kitay-Gorod’)
Moscow 101000 Russia

phone: +7(495)772-95-90 *15026

email: city@hse.ru