Task 1.
This was the most straightforward and easiest task in my opinion because we only had limited work with Arduino. We connected the LED to three different Arduino holes including ground, 5V, and pin 3 following the colors shown in the image. I’ve also successfully passed the LED test by making one light blink by going to the link examples of the Arduino FAST LED category.
Task 2.
I’ve also finished the second task relatively fast because we were given ready codes we needed to copy-paste, and it worked. The installation of the libraries has also been easy since we have seen how to do that before.
Task 3.
This was the most challenging step so far because there were too many questions on how to combine the work of an Arduino with Processing without using the same port at the same time. The step of copy-pasting one Processing code into the second one wasn’t as hard as step three where we had to add different lights to the LED.
Task 4.
This step made the previous one seem like child’s play. And I think without a proper image or a goal of what you want would make the task ten times harder. However, at the end of the day, I went for the same old ellipse which turned out to be a bunch of coins dancing to the beat of Harry Potter’s main theme song.
Code:
Processing.
import processing.serial.*; import osteele.processing.SerialRecord.*; import processing.sound.*; Serial serialPort; SerialRecord serialRecord; int W; //width of the tiles int NUM = 60; //amount of pixels int[] r = new int[NUM]; //red of each tile int[] g = new int[NUM]; //red of each tile int[] b = new int[NUM]; SoundFile sample; Amplitude analysis; void setup() { fullScreen(); size(640, 480); W = width/NUM; String serialPortName = SerialUtils.findArduinoPort(); serialPort = new Serial(this, serialPortName, 9600); serialRecord = new SerialRecord(this, serialPort, 4); serialRecord.logToCanvas(false); ellipseMode(CENTER); sample = new SoundFile(this, "Harry Potter Theme Song.mp3"); sample.loop(); analysis = new Amplitude(this); analysis.input(sample); } void draw() { background(200); float volume = analysis.analyze(); int a = floor(map(volume,0,width,0,height)); float diameter = map(volume, 0, 1, 0, width); for (int i=0; i<60; i ++) { fill(r[a], g[a], b[a]); ellipse(i*W+W*2, height/2, diameter/2,20) ; } r[a] = floor(random(100,255)); g[a] = floor(random(200)); b[a] = floor(random(90)); serialRecord.values[0] = a; serialRecord.values[1] = r[a]; serialRecord.values[2] = g[a]; serialRecord.values[3] = b[a]; serialRecord.send(); }
Arduino
#include "SerialRecord.h" #include #define NUM_LEDS 60 // How many leds in your strip? #define DATA_PIN 3 // Which pin are you connecting Arduino to Data In? CRGB leds[NUM_LEDS]; // Change this number to the number of values you want to receive SerialRecord reader(4); void setup() { Serial.begin(9600); FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS); // Initialize FastLED.setBrightness(10); // BEWARE: external power for full (255) //further info at https://learn.adafruit.com/adafruit-neopixel-uberguide/powering-neopixels } void loop() { if (reader.read()) { for (int i = 0; i < NUM_LEDS; i += 1) { leds[i] = CRGB(reader[1], reader[2], reader[3]); // Prepare the color information using CRGB( Red, Green, Blue FastLED.show(); // Pass the information of color to the LED } } }