Week 11: Interface Programming

For my final project I will be working on creating a sun-fished shaped motion sensitive trash bin that lights up every time someone recycles. In order to achieve this effect, I would have to create electronics and an interface that a. Has a motion sensitive component b. Triggers the sunfish to "light up" when trash is thrown c. Time alotting, can create a network with other trash bins in the vicinity to create other lit animal bins d. Other bins light up when enough trash has been reached (so there needs to be some type of counter in the system)

First I tried to create a new board that has motion sensor and LED components to it. But realizing the time constraints for this week and trying to minimize uncertainties on what has been a rather precarious journey through embedded programming, I wanted to be able to focus on the interfacing programming portion rather than be stuck in the circuits design

So, I used an arduino instead. RANT: Honestly for someone who has had 0 electronics experience and negligible programming experience, I found the arduino to be a much more straight forward process in understanding how electronics work. For amateurs, I feel that trying to recreate our own circuit boards from the beginning...many of us who are actually still struggling on the milling process, or debunking EAGLE's clunky interface: Ultimately, we become overwhelmed with not isolating what the heart of the problem is. Also, I found my peer group in the arch section struggling quite a bit throughout the electronics modules (Well, I can speak for myself), and we could benefit from a cross-pollination with the EECS section.

Since I am lightly familiar with processing, I learned to connect processing with arduino using this handy guide:

PROCESSING FROM ARDUINO

This helped me learn the basic structure for setting up a connection between my devices and processing. There are 3 main components in connecting the arduino to processing and to my devices

1. Create the set up method which sends data between the computer and the code

void setup() { //initialize serial communications at a 9600 baud rate Serial.begin(9600); }

2. Create a loop

void loop() { //send 'Hello, world!' over the serial port Serial.println("Hello, world!"); //wait 100 milliseconds so we don't drive ourselves crazy delay(100); }

3. Make Contact

void establishContact() { while (Serial.available() <= 0) { Serial.println("A"); // send a capital A delay(300); } }

Finally my code in processing looks like this:

My code in arduino looks like this:

2 Libraries to load in: 1. Adafruit Neopixels 2. Newping.h

I intended the code to do the following: After 20 pieces of trash have been thrown in, at intervals of 5, the colors become less vibrant. So we go from a fully RGB schematic to a chromatic scale