Putting it all together

Code from class, circuit schematics, etc. are at the bottom

Let’s get the chocolate in the peanut butter

  • Serial communication – you’ve already done this! Serial monitor in Arduino
    • Give us even more power to compare different things in unique and weird ways
    • sending voltage along the USB cable to represent numbers, letters, and punctuation
      • one number/letter is easy
      • more will require you to make up your own protocol (agreement between systems)
        • Physical system is already determined for us, as is the mechanism for communication.
        • We’re gonna make up our own words and hooks that uniquely identify our information (formatting above all else)
        • baud rate must be in agreement
      • println() on Arduino side – just like the serial monitor. Gonna replace the duck with a processing program
  • Processing doesn’t have a native idea of serial (Arduino can only communicate with one other thing, Processing can communicate with many at the same time).
    • Make sure Arduino is sending information
    • Close serial monitor (Ardy can only talk to one at a time)
    • import serial lib
    • make serial object & initialize
      • need to choose the correct port
    • set up listener/callback/what have you

      This gets paired with a freebie function serialEvent. It waits until a newline character (the ‘\n’) is received.

      • This converts the text from Arduino into numbers that Processing can use.
  • Arduino can send raw bytes (an 8-bit value between 0-255), and that’s great if you’re an engineer. For the rest of us, it’s better to think about text. It’s easier to read & debug, you can send arbitrarily long numbers, and it’s easier to send multiple pieces of data because it allows for non-numeric characters that can act as delimiters.
    • How ASCII works
  • ASCII Table┬áis the nerdiest website I know by heart.
  • sending multiple bits from Arduino to Processing (CallResponseASCII)
  • Sending from Processing to Arduino (Physical Pixel)
    • This is the exception to the rule, it’s easier to send bytes to a micro controller. (physical pixel/dimmer)
    • Picture to Pixel
  • Examples from class
    Space Invaders (Handshake, 2 sensors to Processing)
    Pixel to RGB LED (multiple bytes to Arduino)
    Dimmer (one byte to Arduino)
    Expanding Circle (one sensor to Processing)

Comments are closed.