I had some problems with the ‘Tweak the Arduino Logo’ experiment. The main issue was that the mini-window the Arduino logo appeared in only held the bounds of the image. It showed no background, and was non-resizable (meaning if you were using a non-transparent logo file format, you wouldn’t know if it was working). The other issue I uncovered was the speed at which the potentiometer was allowed to output data. In the provided code they specified delay(1), but this was much too fast — delay(100) provided better results.
So, below, I’ve provided slightly modified code which worked for me.
First the Arduino code. The only change was the delay() value.
1 2 3 4 5 6 7 8 9 10 11 |
void setup() { // put your setup code here, to run once: Serial.begin(9600); } void loop() { // put your main code here, to run repeatedly: Serial.write(analogRead(A0) / 4); delay(100); } |
Next we have the Processing code. In this code, I’ve created a larger window (twice the size of the specified image), and placed the image in the centre of this window, so the background colour is easily visible.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import processing.serial.*; Serial myPort; PImage logo; int bgColor = 0; void setup() { colorMode(HSB, 255); logo = loadImage("arduino_icon.png"); size(logo.width * 2, logo.height * 2); println("Available Serial ports: "); println(Serial.list()); myPort = new Serial(this, Serial.list()[0], 9600); } void draw() { if(myPort.available() > 0) { bgColor = myPort.read(); myPort.clear(); println(bgColor); } background(bgColor, 255, 255); image(logo, logo.width / 2, logo.height / 2); } |
A screenshot:
The circuit was nice and easy to make:
Pingback: Article: Tweak the Arduino Logo – making it work - VISUALS+CODE