Skip to content

A pragmatic method for learning serial communication between Arduino microcontrollers and Max software (by Cycling'74)

Notifications You must be signed in to change notification settings

benjohansen/20projects_arduino-max

Repository files navigation

This is a work in progress (beginning Feb.2022).

Purpose

Completely pull back the curtain and explain how every detail of serial communication works between Arduino microcontrollers and Max software (by Cycling'74). This is a pragmatic method offers 20 projects with clear, thoroughly commented code.

These projects only use native Max objects and were written for Sparkfun's Arduino based Digital Sandbox that has real-world inputs and outputs built into one board ... but, with a little physical computing and a very small amount of code editing, any Arduino will work.

I was especially inspired by Darwin Grosse's "20 Objects" course and Sparkfun's "Digital Sandbox Arduino Companion" written by Jim Lindblom.

Requirements

  1. install Max
  2. Install FTDI (USB) Drivers photo of the FTDI driver page
  3. Install the Arduino IDE
  4. to upload sketches to the Digital Sandbox within the Arduino IDE: go to the "Tools" menu, select the Arduino Pro or Pro Mini as the board type and ATmega328P (3.3V, 8 MHz) as the processor type; also be sure to choose the correct USB serial port.

Table of Contents

Arduino to Max (reading Ardiuno input in Max)

Max to Arduino (controlling Arduino output from Max)

  • 04_LED
    • use Max to control one LED attached to the Digital Sandbox
    • based on Sparkfun's "1. Exploring Blink" experiment
    • similar to Arduino's "Blink" built-in example
  • 05_5LEDs
    • use Max to control the Digital Sandbox's row of five LEDs
    • this example shows how to send more than one piece of data from Max to the Arduino
    • based on Sparkfun's "2. Multi-Blink" experiment
  • 06_dimLED
    • use Max to control the dimming (using PWM) of an LED on the Digital Sandbox
    • based on Sparkfun's "4. Dimming (the Easy Way)" experiment
    • similar to Arduino's Fade built-in example
    • will work for a motor (DS Addon) by changing output pin number to 3 (similar to and simpler than Sparkfun's "15. Serial Motoring (Addon))" experiment, with just one-way communication)
  • 07_dim2LEDs
    • use Max to control the dimming (using PWM) of two LEDs on the Digital Sandbox
    • based on Sparkfun's "4. Dimming (the Easy Way)" experiment
  • 08_RGBLED
    • use Max to control the color (using PWM) of the RGB LED on the Digital Sandbox
    • based on Sparkfun's "5. Color Mixing" experiment
    • similar to Arduino's "Read ASCII String" built-in example
  • 09_servo
    • use Max to control a servo motor hooked to the Digital Sandbox (using pulsed digital out - not PWM)
    • based on Sparkfun's "16. Servo Sweeper (Addon)" experiment
    • make sure the "charge" switch on the Digital SandBox is in the "off" position
  • 10_piezo
    • use Max to control the frequency output of a buzzer hooked to the Digital Sandbox (using PWM)
    • based on Sparkfun's "14. Opto-Theremin (Addon)" experiment

Both Directions

Projects 13-20 coming soon ...


About the Sparkfun Digital Sandbox

Sparkfun Digital Sandbox product page

Sparkfun Digital Sandbox interactive simulation by Bitsbox

Microcontroller chip

  • ATMEGA328P (32kB of flash program memory and 2kB of internal SRAM) - the Sparkfun Digital Sandbox has an 8MHz clock speed

Built-in inputs

  • temperature sensor on A0 pin
  • light sensor on A1 pin
  • microphone on A2 pin
  • slide potentiometer on A3 pin
  • slide switch on D2 pin
  • push button on D12 pins

Built-in outputs

  • LED bar graph on D4-D8 pins
  • RGB LED on D9 (red), D10 (green), and D11 (blue) pins
  • 3-pin add-on header with VCC (5V), GND, and pin D3
  • 4-pin header with 3.3V, GND, A4 (SDA) pin, and A5 (SDL) pin

photo of the Sparkfun Digital Sandbox


Wireless communication using XBee modules

  • In short: I have concluded it isn't worth implementing wireless communication using XBees with the Sparkfun Digital SandBox
  • I used multiple software serial libraries with various combinations of pins 11, 12, 13, and A4 (14) and A5 (15). I got it to work ... but communication often created an incorrect/unstable output and input.
  • I want these fundamental examples to be very stable, so I will be suggesting hardware serial communication for students starting out ... unfortunately, the Digital Sandbox only has one hardware serial port.

Releases

No releases published

Packages

No packages published