top of page

Arduino Homework_Allen Zhou

 

 
Week2
 

Task 1: photoresistor/photocell

 

After started with the blinking example in the arduino software, I opened the door behind which was full of novelties that I didn't know before. Actually the first experiment i did was not the blinking example but the photoresistor circuit cuz that was the first sensor I put on my arduinoboard.

 

In this circuit, I connected one side of the photoresistor to the power(5V) and connected the other side to GND with a 10K Ohm resistor. And i also use the Serial.println() function to print out the current value of the photocell voltage on the serial monitor, which represents the brightness of the background light.

 

Here is the sentences&schemetic of this simple circuit.

 

 

 

 

 

 

 

int photocellPin = 0; 

int photocellVal = 0; 

   

void setup() {  

  Serial.begin(9600);  

}  

   

void loop() {  

   

  photocellVal = analogRead(photocellPin);  

  Serial.println(photocellVal);    

  delay(100);         

}  

Task 2: voltage divider

 

The second task this week is called "voltage divider". By removing the photocell and replacing that place with two open wires(yellow and green wires in the following picture), I created a very simple voltage divider(or switch). When the two wires are disconnected, the resistor between the two wires are infinite(cuz air is perfect insulator) so compared to infinite, 10K is really a small number so the voltage between the two wires is 5V and the voltage between the two ends of the 10K resistor is down to zero.

 

In contrast, when the wires are connected to each other, the voltage between the two wires is down to zero since compared to 10K, the resistor of connected wires is too small to be noticed. More importantly, this simple circuit can also be used as a basic digital switch which has two states, ON and OFF(0/1). When the wires are connected, the switch is closed and the state is 1, when the wires are disconnected, the switch is open and the state is 0.

 

   

Switch OFF

Switch OFF

Switch ON

bottom of page