Academy 2013

Input Devices
inputweek
hello.reflect.45
This weeks project was to make an input sensor, connect it to and microcontroller and run it. In the beginning of the semester when I was preparing for the academy I milled out all of the boards for input and output week from the website so that gave me a lot more time to study the programming instead of spending a lot of time milling out circuit boards.

hello.txrx

I made a board called hello.txrx, which is a step response. First thing I did was connecting the board to an AVR microcontroller (I tried the boards out on the AVR first because it gives me a green light if it is connecting or not). When I saw that the boards where working fine I used my Fab ISP.
I downloaded the make file and the python file and put them in a folder I made on my desktop
Next I opened the Terminal and found the folder there. Now I plugged both the AVR microcontroller and the hello.txrx to my computer in the USB ports.
To send the program to the board I had to run the .make file. I did that by writing:
         sudo make -f hello.txrx.45.make
         sudo make -f hello.txrx.45.make program-avrisp2

If you're using an FabISP instead of AVR microcontroller write: sudo make -f hello.txrx.45.make program-usbtiny

After that you can unplug the microcontroller but keep the board connected too an USB port through an ftdi cable. The ftdi cable is used for electricity, not for sending files.
Now I had to figure out the name of the USB port I was using. I did that by writing ls /dev in the Terminal, unplug the cable and write it again. By doing this I could search the which port was in use when the ftdi cable was in the computer. This time it was called ttyUSB0.

Here you can see the ttyUSB0 marked with red color
input2

When I had the name of the port I could run the python file by writing:
         python hello.txrx.45.py /dev/ttyUSB0

Now a window opened up with a bar that ether went up or down if the electrical conductivity changes. To see any changes I cut out four pieces of copper sticker, solder them to four different wires and put them on the board to see the bar move

Here is my hello.txrx connected to the Fab ISP I made few weeks ago

hello.txrx

Here are the copper stickers connected to the hello.txrx board.
By making them touch each other the bar on my computer went up or down

coppersticker

Here is the Terminal running the hello.txrx

hello.txrx_terminal

hello.reflect

Next board I made was a hello.reflect. The reflect board is a light sensor with a LED light and a phototransistor that catches the reflection from the LED light. The programming works just like on the hello.txrx but after I did that nothing happened. I got the bar window open but it didn't change at all. I had no idea what was wrong until I found this picture of Neils board. There I saw that the phototransistor was facing the other way on his board. After I changed that the LED light went on and my board was working great.

here is the hello.reflect working properly

hello.reflect

hello.temp

After the reflect I kept making more inputs. Next up was a hello.temp which is a temperature sensor. The codes are mostly the same as on the other boards so I am going to put a picture of the Terminal with the codes and the bar window.

hello.temp

hello.button

Hello.button is a board with a button. After the board has been programed and you press the button there should appear two letters on the Terminal, d and u, for down and up.

         sudo make -f hello.button.45.make
         sudo make -f hello.button.45.make program-usbtiny

Here is the python file running and when I pressed the button I got the letters d and u

hello.button


After I saw that the board was working fine I wanted to write something else than d and u so I opened the .c file by writing:
          gedit hello.button.45.c

Now there should open up a text editor with the codes for the switch. I wanted to make the button write my first name if I pressed it down and my middle name when I released it. I saw this code and decided to change it:       
     ;put_char(&serial_port, serial_pin_out, 'd')
I changed the "d" to "bjartur" but the program always answered with an error when I tried to run it.
Then tried to write all that code again for every letter so this is what it looked like:

while (0 != pin_test(input_pins,input_pin))
        ;put_char(&serial_port, serial_pin_out, 'b')
;put_char(&serial_port, serial_pin_out, 'j')
;put_char(&serial_port, serial_pin_out, 'a')
;put_char(&serial_port, serial_pin_out, 'r')
;put_char(&serial_port, serial_pin_out, 't')
;put_char(&serial_port, serial_pin_out, 'u')
;put_char(&serial_port, serial_pin_out, 'r')
; //
I did the same thing with the code where the "u" was and wrote down my middle name "tyr". Now I ran the program and it was working just like I wanted to. When I pressed it down it said "bjartur" and when I released it I got "tyr" on the screen.
Here is the button saying bjartur tyr

bjartur_button

 

fablab
Vestmannaeyjar, Iceland