Menu

Reattached Input Week and modified Neil's Synchronous Light Board to have a separate sensor board and to output using Kivy instead of Tkinter.

Creating a Synchronous Light Sensor

I want to use the light proximity sensor for my final project. For input week, I tried creating a sonar proximity sensor. However, I did not get around to loading the final code. I later found out that the sonar is not great for picking up really close object and I want my final sensor to be able to tell when it is next to something. Because I plan on placing the sensor on the side of a table, I knew the sensor itself would probably have to be mounted separate from the board. I modified Neil's board into two using a 2x2 header. Click the below pictures to download the complete KiCad project. My Week 9 page has my notes on the KiCad workflow.

You can download the png files for the two boards below:

Learning Kivy

I learned Python over the summer and wanted to try my hand at using Kivy with it. Kivy is a Python GUI interface that is supposed to be especially good for touch interfaces such as mobile applications. While my final project would not need a touch interface, I thought it would be a useful skill. I also need to see the outputs of my sensor board to program my project correctly. I started by going through the Kivy tutorial on making a pong game. Click the below picture to download the pong game.

Programming a Graphical Output on Kivy

Since I am still a novice at Python and I had just done one tutorial on Kivy, I looked for help from the internet on finding a graphical output and figuring out how to combine that with Neil's original python code. I found this useful post on stackoverflow on making a circular progress bar. With circuit design and a rough draft of my python script in hand, I went to the Architecture shop.

Loading the program with Atmel Ice

After milling the two boards and trying to load the program with my USBTiny, I got the dreaded RC-1! After testing my board with the multimeter and discovering nothing wrong, I finally determined that my USBTiny had gotten bad. When I plugged it into my board, I noticed that both the red and green lights lit up. It had been sitting in a tupperware containter being jostled around for half a semester. So instead I just used the Atmel Ice in the shop. I connected the FTDI cable as usual. Then connected the ICE header to my board - note: black nub should face in away from VCC and Ground connections. And then used this command to tell the make file.to use the Atmel ICE to load the C code: $ sudo make -f hello.reflect.45.make followed by $ sudo make -f hello.reflect.45.make program-ice. No fuses line was needed for this code. Note that extra 6 pin connecting is really a 4 pin connection to my seperate light sensor board that can be seen on the far right.

Python, FTDI and ports!

So I had not interacted with a board yet using python and an FTDI cable. To test things out, I just used Neil's original python code. And everytime it shot back at me with: command line: hello.light.45.py serial_port. I finally realized that was Neil telling me include the serial_port in the command. I then had the darnest time finding the serial port using an Ubuntu Linux machine. I finally found a script online that told the terminal to spit out a list.

So I then ran $ sudo python hello.reflect.45.py /dev/ttyUSB0. That got me the below video. Yes! Except the diff scroll was doing something funny. When I closed the circuit with my finger, it went negative. I quickly realized aI had installed the sensor backwards. Green side downstream on the Cathode!

Below is an image of it backwards. Reversed it and success!

Getting Kivy to Work

Almost done. Loaded up my Kivy program on my computer. Had a couple issues that I was able to work through. Some of my variables were not in the right place. Moved those around. Had an issue where I had to put "()" around the print statements. And also was getting an error with serial. Ended up uninstalling serial and reinstalling it using the following commands: $ pip uninstall serial, then $ pip install pyserial