Week 10: Input Devices
• Assignments
This week’s assignments
measure something: add a sensor to a microcontroller board that you've designed and read it
TCRT 5000 is a reflective optical sensor with transistor that typically used by line followers. It is a simple analog sensor.
PCB
Top View
Side View
The LED with flashing in different speed according to the input.
Code
#define LED 3
#define IR A2
int adc=0;
void setup()
{
pinMode(LED, OUTPUT);
}
void loop()
{
digitalWrite(LED,HIGH);
adc=analogRead(IR);
delay(adc);
digitalWrite(LED,LOW);
delay(256-adc);
}
Get the files
You can download the source files directly.