top of page

Observation of every day things & Servo Motor+IR Sensor lab.

The laundromat is a common place for people to go through on once a week basis. The machines differ from places to places, depending on how new the establishment is, which will also determine that the machines they use would probably be new. I used to visit a nostalgic laundromat, the place looked rather tired, the machines are old and the whole design of the space is screaming for a revamp. The machines however, was really easy to use, you read the instructions, follow accordingly, insert the correct number of coins and you wait.

Recently, I wanted a change of tune. I went to a different laundromat which was relatively new. The machines was gorgeous looking, the shine from the machines greeted me as I entered. They use a different system with their method of payment. They used a card instead. Modern! I said to myself. Using the wash was relatively easy, you choose the wash option you want and insert the card. The dryer however, I struggled a little, well, actually a lot. The concept of the dryer was, you put in the card and it will automatically dry your clothes for 10mins. Considering I have numerous experience in doing my own laundry, I knew that 10 mins was not enough to dry my clothes. But there was no option to extend the drying time. I waited for 10mins and repeat the cycle again. While I was waiting, I observed people using the dryer, most, if not all handled it quite well. They insert the card multiple times to increase the duration of the dryer. They based the mechanics on the traditional way which was to use coins. But, this is a modern machine, do I really want a nostalgic concept placed in a new machine?

While waiting, I kept pondering on that question and was trying to think of other mechanics that use the same system, where they use an old technique and place it in the new machine. I am however not comfortable with the way the machine operate. As much as I am comfortable with an old technique because I am used to it, but, once place in a modern machine, my mind could not comprehend. Primarily because my mind is used to telling me that a new machine equates to a new technique where I will learn and my mind is expecting some visual cues so that I can understand it better.

THE LAB

This week, I wanted to use the servo and the IR sensor in an enclosure. I came out with the idea of a robot, I thought it would be great to have something that I could interact with that mimic a robot.

The button once HIGH, if(buttonValue==HIGH){ the servoMotor would read it and move 180, servoMotor.Write(189); and delay for 50ms, else the servoMotor would read (0) if LOW. Once the button is pressed, the antenna of the robot would rotate 180.

THE IR SENSOR

I did not set the map for the IR Sensor, I wanted it to be on and off thus I used the if(analogValue > 100) statement and once this is triggered, the speaker would play the tone.

The code

#include <Servo.h> #include "pitches.h"

Servo servoMotor; // creates an instance of the servo object to control a servo int servoPin = 2; // Control pin for servo motor #define irPin A1 #define speaker 6 #define button A0

void setup() { Serial.begin(9600); // initialize serial communications servoMotor.attach(servoPin); // attaches the servo on pin 2 to the servo object //pinMode(button, INPUT); // set the switch pin to be an input }

void loop() { int analogValue = analogRead(irPin); // read the analog input int buttonValue = digitalRead(button); // read the analog input Serial.println(analogValue); // print it

//int servoAngle = map(buttonValue, 0, 1000, 0, 180);

//button if (buttonValue == HIGH) { servoMotor.write(180); delay(50); } else { servoMotor.write(0); }

//tone. Credits: https://mycontraption.com/sound-effects-with-and-arduino/ if (analogValue > 100) { tone(speaker, NOTE_A7, 100); //G delay(50); tone(speaker, NOTE_G7, 100); //G delay(50); tone(speaker, NOTE_E7, 100); //E delay(50); tone(speaker, NOTE_C7, 100); //C delay(50); tone(speaker, NOTE_D7, 100); //D delay(50); tone(speaker, NOTE_B7, 100); //B delay(50); tone(speaker, NOTE_F7, 100); //F delay(50); tone(speaker, NOTE_C8, 100); //C delay(50); tone(speaker, NOTE_A7, 100); //A delay(50); tone(speaker, NOTE_G7, 100); //G delay(50); tone(speaker, NOTE_E7, 100); //E delay(50); tone(speaker, NOTE_C7, 100); //C delay(50); tone(speaker, NOTE_D7, 100); //D delay(50); tone(speaker, NOTE_B7, 100); //B delay(50); tone(speaker, NOTE_F7, 100); //F delay(50); tone(speaker, NOTE_C8, 100); //C delay(50); } noTone(speaker);

}

Featured Posts