Digital/ Analogue Input and output

 

During the lab, I covered digital input & output and analogue input. Learning points are:

  • Resistors used in button is pull down resistor, which stabilizes the input value.
  • digitalWrite() vs analogueWrite()
  • Finding the sensor range
  • Const int: something that never changes value, such as a pin number, less is used
lab1: digital input and output using buttons, LED, and piezo buzzer

How it works:
Press the button(on the lower bread board) and listen to the sound.
Compound and duplicate the sound heard, by pressing the buttons to light up the LED

More to do:
Haven’t figured out how to store  the order of the button pressed. So, for now after green BT is pressed, the LED lights up.
Q) Is array the answer for storing the order of the BT pressed?

 

lab2: Analogue input and output using FSR, and LED

How it works:
Press the force sensing resistor to light up the LED.
FSR requires 10K ohm

Finding & converting the sensor range:

  • simply reading
    sensorReading = analogRead(A0);
  • converting from ADC to voltage
    voltage = sensorReading * (5.0 / 1024.0);
  • mapping
    lightness = map(sensorReading, 0, 1023, 0, 3);