WEEK 10 | Input Devices
Bread board - Capacitive Sensor Test
Alternatives:
Capacitive sensor | Inductive sensor | "Home made" switch | Reflective sensor
I decided to do some tests to decide which one to use.
This example is the capacitive sensor. It works very well with fingers. With the marble, the variation was different every time I tried. So it was complicated to find the right value to make something happen when the marble touches the capacitive sensor. So I decided to focus on the "home made" switch.
Bread board - Switch Test
- To know how to dispose the "copper tape switch"
- To test the sensor's sensitivity.
As you can see on the picture, this input worked well for what I wanna do. So I decided to focus on this one for this week's assignment.
How the AttachInterrupt() function works on Arduino:
AttachInterrupt is set up on the "switch" pin. When the voltage is FALLING on this pin, AttachInterrupts activated another function. I used a function that changed the LED color. So AttachInterrupt() knew that the marble was closing the circuit because the voltage was dropping from 5V to 0V in the "switch" pin.
It's time to make the board
Here, download:
- the .png files: traces and board.
- the eagle files: schematic and board.
Programming
First of all I had issues with the NeoPixel library which was working with Arduino Uno. I needed a 20MHz resonator in order to use it. So I downloaded the new FastLED library and changed the code. But the board wasn't doing what I expected it to do, the LED color wasn't changing. I decided to do some tests to understand what was happening (see below).
In the middle of this big reflexion I smoked my board... I have no idea how I managed to do that. However, I had to replace my ATtiny45 and the regulator.
Conclusion:
The program was working with Arduino Uno, I burnt the bootloader, the LED and the switch were working independently. The problem was the AttachInterrupt() function, it doesn't work with an ATtiny45 or maybe I did something wrong!
At the end, I used the digitalRead() function instead of this fancy AttachInterrupt() function and it worked!