(click on the tabs below)

Magnetism

In today's session, we learned more about electronics and sensors for circuits. There is a magnetic field sensor that can change voltage if a magnetic field comes closer. The voltage starts in about 2.5 volts (1/2 of voltage) and gets stronger if a positive magnetic change gets close to the sensor, and weaker if a negative one gets closer. Below is a picture of the sensor (looks like a transistor):

Another type of sensor is an accelerometer. This sensor is inside a box and the sensor is attached to a spring. With the effect of gravity, the sensor either gets close to one side of the box or another depending on the orientation of the box. This sensor sends this distance from every side to measure the force of gravity on the object.

Light

The next sensor is a photoresistor. They provide a little bit of current when hit with lights. The current basically adds together the previous voltage before the photoresistor's addition of the light's voltage. They are used to sense objects in front of the photoresistor, to sense if something is blocking a light to give an action, etc...

Temperature

The next sensor is a temperature sensor. It measures the surrounding temperature and changes voltage running through it accordingly to the change in temperature. You can also use this sensor to sense if the surrounding temperature surpasses a point, the sensor can open the current so that an action takes place such as turning in a fan, etc...

Capacitance

You can take two capasitors and make a signal between both of them. They can sense if they are getting blocked by something or if they are getting farther away by sending blimps from both capacitors, either low or high blips, that represent the signal being good or bad.

Homework

After seeing the lesson on the whole arsenal of sensors we have acces to, I decided to use a phototransistor for the homework assignment. In this assignment, we were challenged to make a sensor send information to the Arduino which would send a command to anything from a DC motor to an LED. I made it so a phototransistor would measure the amount of light around it and send a higher voltage to two LEDs if there was no lights, or send a lower voltage to the LEDs if there was more light. Here are videos of the LEDs responding to the phototransistor; There is also a screenshot of the Arduino code below:

Finished Product

Click here to download Arduino Code

In today's lab, we messed around more with sensors. I perfected my phototransistor sensor in the lab. I changed the phototransistor from an infrared to a light sensor, which captured change in light much easier. I also changed it so the LEDs would only turn on when light was shined on them. Here is a video of this process and the Arduino code is also attahced below:

int photoTran=A3; //phototransistor connected to analog pin 3 int ledPin=13; //led is connected to pin 13 (on-board led) void setup(){ pinMode(ledPin,OUTPUT); pinMode(3,INPUT); Serial.begin(9600); } void loop(){ int tran = analogRead(photoTran); //read the phototransistor Serial.println(tran); if (tran<970) {digitalWrite(ledPin,HIGH);} else {digitalWrite(ledPin,LOW);} }

Another thing I did during this lab day was finishing my rough prototype. I made it so that the two wheels can be controlled with different potentiometers. This lets the car turn to the left and right, and go forwards. Here is a video of how the potentiometers control both wheels:

Below is the code for the dual-motor car

const int POT_PIN_1 = A0; const int MOTOR_PIN_1 = 9; const int POT_PIN_2 = A1; const int MOTOR_PIN_2 = 11; int motorSpeed = 0; int potVal = 0; void setup() { pinMode(MOTOR_PIN_1, OUTPUT); pinMode(MOTOR_PIN_2, OUTPUT); } void loop() { potVal = analogRead(POT_PIN_1); motorSpeed = map(potVal, 0, 1023, 0, 255); analogWrite(MOTOR_PIN_1, motorSpeed); potVal = analogRead(POT_PIN_2); motorSpeed = map(potVal, 0, 1023, 0, 255); analogWrite(MOTOR_PIN_2, motorSpeed); }