Skip to content

13. Input Devices

For this weeks work the ‘Input’ is a potentiometer. We read an analog value as an input and use that to control a PWM signal that drives an output.

Group Work

In the group work I found out that my slide potentiometer does indeed appear to be linear. An that an Ultrasonic range finder, though not recommended for new designs, is surprisingly accurate.

Input Device

For our Output Devices week we created a board that used a slide potentiometer to control a fan, two birds with one board.

Output Devices details the design and construction of the board.

Files

KiCAD

Schematic
Tracks
Outline

Code

Programmed using the Arduino IDE, (with the SpenceKonde/megaTinyCore board support installed), via the ‘SerialUPDI - SLOW’ option.

void setup() {
  PORTA_DIR |= (1 << PIN_PA3);
}

void loop() {
  analogWrite(PIN_PA3, analogRead(PIN_PA1) >> 2);
  delay(100);
}

Minor Coding Issue

Initially wrote the first line as ‘DDRA |= …’ Found out that it didn’t compile and had to find the correct defined alias for the register.

Hero shot

It works as expected (excuse the rattling in the background) In the video here you can see the sophisticated fan flow indicator responding to the different amount of air being pushed at different set positions og the slide potentiometer:


Last update: June 27, 2022