Skip to content

Instantly share code, notes, and snippets.

@diessica
Last active February 10, 2018 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diessica/435a6dd24aced479003f0c4e411abf29 to your computer and use it in GitHub Desktop.
Save diessica/435a6dd24aced479003f0c4e411abf29 to your computer and use it in GitHub Desktop.
arduino + python interface (testing serial)
int PIN = 7;
char message;
void setup() {
Serial.begin(9600);
pinMode(PIN, OUTPUT);
}
void loop() {
if (Serial.available() > 0) {
message = Serial.read();
if (message == 'A') {
digitalWrite(PIN, HIGH);
}
if (message == 'B') {
digitalWrite(PIN, LOW);
}
}
}
  1. interface microphone -> python (pyaudio)
  2. microphone audio -> spectrum analyse
  3. analysis > generate color values in one char
  4. rgb values -> arduino
  5. arduino > manipulate stripe colors (neopixel)

stripe colors manipulation

from sound's FREQUENCY and AMPLITUDE, we send an array with a (0,255) value based on amplitude for each of the 60 LEDS.

led[0] = amplitude
led[1] = amplitude
led[2] = ...
import serial
import time
arduino = serial.Serial("/dev/cu.wchusbserial1430", 9600)
time.sleep(2)
arduino.write("A")
print 'wrote A'
time.sleep(0.5)
arduino.write("B")
print 'wrote B'
arduino.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment