Skip to content

12. Output devices

Assignments for the week

Group assignments

  • Measure the power consumption of an output device

Individual assignment

  • add an output device to a microcontroller board you’ve designed, and program it to do something.

Requirements

  • Described your design and fabrication process using words/images/screenshots, or linked to previous examples.
  • Explained the programming process/es you used and how the microcontroller datasheet helped you.
  • Outlined problems and how you fixed them.
  • Included original design files and code.

Group assignments

See 2019 Fablab Taipei Group site Week 12

Individual assignment

Design

Modified the code of week 11, from digitalRead() to analogRead().

Princeple of LED as input

When a LED exposes to light, It will generate a voltage difference between two pins just like PV pannels.
On the other hand, light-sensitive resistor only change it’s resistance.

Datasheet of ATtiny 45

Download Datasheet of ATtiny 45 here,
and It says:


When designing a system where debugWIRE will be used,   
the following must be observed:   
• Pull-Up resistor on the dW/(RESET) line must be in the range of 10k to 20 k. 
  However, the pull-up resistor is optional.  
• Connecting the RESET pin directly to VCC will not work.   
• Capacitors inserted on the RESET pin must be disconnected when using debugWire.   
• All external reset sources must be disconnected.

No debugWIRE used by this board, so It do not need a resistor compare to echo hello-world board

Add a capacitor to make the power supply more stable.

Two LED in series to be a voltage input

6-pin SPI as the programing interface.

Board

Drawing progress is on Eagle, same as week 7. Electronics design.

BOM

Parts Spec. Quantity
ATtiny 45 1
Resistor 220 ohm 1
LED Yellow 3
Heder 2x3 1
1x2 1

Make the board and Test It

Code


/*
Week 12 assignments for Fab academy 2019
*/

// Pin3 is In and pin4 is Out 
void setup() {
// initialize digital pin as input and output.
pinMode(3, INPUT);
pinMode(4, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
int response= analogRead(3)/20;

    digitalWrite(4, HIGH);   // LED on time
    delay(response);
    digitalWrite(4, LOW);    // LED off time
    delay(response);

Files

Board
Outline