Skip to content

Latest commit

 

History

History

06_arduino

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Teachable Machine + Arduino

Objectives

  • Review sound classifier
  • Understand the communication between p5 sketch, Teachable Machine models and the Arduino board.
  • What is serial communication?

Workshop:

Sound Classifier with Arduino and Teachable Machine

Steps

void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(2, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(2, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(2, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

https://teachablemachine.withgoogle.com/models/80pkk7maP/

  1. Download Arduino IDE
  2. Download p5 serial app (Don't open the app yet)
  3. Run p5 code in p5 web editor sketch (Remember to update the portName and mySoundModelURL, and update class names to your own classes.)
  4. Build the arduino circuit like the image above
  5. Upload Arduino code to the Arduino board, You can find here
  6. Open p5 serial app(don't open any port in the p5 serial app, just keep the app open)
  7. Go back to p5 web editor, test if p5 sketch and arduino can communicate.

Sound Classifier with Arduino and Teachable Machine with Servo Motor

  • Upload the Arduino Sketch to the Arduino board
  • Running p5 sketch, remember to update the portName and mySoundModelURL, and update class names to your own classes.
  • Video Demo
  • Circuit
    • Connect D2,3,4 to 3 LEDs
    • Connect servo signal pin to D9. More about how to use servo motor with arduino. sound_servo

Image Classifier with Arduino:

  • Running this p5 sketch on p5 web editor, remember to update the portName and myImageModelURL, and update class names to your own classes.
  • Video Demo

Pose Classifier with Arduino:

  • Running this p5 sketch on p5 web editor, remember to update the portName and poseModelUrl, and update class names to your own classes.
  • Video Demo

Help

Trouble shooting:

  • The models works in p5 web editor, but my LEDs are not lighted up
    • Light up LEDs in the arduino code directly to test if there is anything wrong with the LEDs.
    • Make sure p5 serial is working: There shouldn't be any error in the console. The p5 serial app should be open, but do NOT connect to the port inside of the p5 serial app, otherwise p5 serial app will be using the port, then p5 web editor cannot use the port.
    • You can find your portname in the p5 serial app. But there is no need to connect to the port in the p5 serial app.
    • When you are re-uploading Arduino sketch, you need to stop p5 sketch in the editor and close the p5 serial app.

See demos live:

Links

Inspirations about Teachable Machine:

Assignment

Video

Coding

  • Build an interactive browser experiment related to sound/image/pose/hand data, with an Arduino component.
  • Document your p5.js sketch in a blog post and add a link to the post / your p5 sketch on the homework wiki. In your blog post, include visual documentation such as a recorded screen capture / video / GIFs of your sketch.