Week assignments
Group assignment
- probe an input device's analog levels and digital signals
Individual assignments
- Measure something: add a sensor to a microcontroller board that you have designed and read it.
Group assignement
You can find documentation about our group assignement on our group page.
Designing a 2*2 switch button matrix
My final project is about to design an electric chessboard. I am still not sure on how to detect chessmoves but I know I am gonna have to use matrix of sensor.
Therefore, I choosed to design a matrix of 4 switch button. This example don't make me save I/O pins since I am still going to need 4 of them but the logic will be the same.
Electronic design
You can get my KiCAD archive for this week here
Below is the schematic used for this week. I helped my self with this arduino tutorial.
The idea of the matrix is to have line i and column i connected if the i*i button is pressed.
I was struggling with routes drawing in PCBnew thus I decided to move my pins to help myself. But I made a mistake moving L2 label to pin 13 instead of pin 7 where MOSI is supposed to be connected to AVR header. Hoppefully this mistake was easily solvable by using RXD pin of the FTDI header.
I realized this week in PCBnew that drawing the routes can become complicated with many components. Eventually I found a solution to my design but I forgot one route highligted in white below. Thus, at the end I had to add a jumper wire.
The board milled very fine and I was able to solder my components
Testing FTDI monitoring
My first trial was to be able to receive a serial information through FTDI cable, thus I tried this code:
At first I reversed RX and TX pin because I didn't understand well how the library was working. But we actually have to be in the shoes of the computer and not them of the board.
After this correction the code was working well.
Programming one button
I wanted to try first the behaviour of the board programming only one button. Here is my code:
This code was working fine. Below is the result. But here only one button was soldered. I will realize in the next step that it is not consistent to do it this way.
Programming with four button
Detecting the lines
To detect a button, you have to know its line and column. First step is to detect the line:
I reversed the logic in this code compared to the 1 switch test. Indeed, with the 4 buttons soldered, voltage to l1 pin was not LOW, it was about 1.5V and detected as HIGH. Using the built-in pullup resistor allowed me to have a consistent 5V when button is not pressed and a consistent LOW when button is pressed. This code is working well.
Detecting the button
Still troubleshooting this part.