pComp Final - starting the tree

Okay, so my to-do list for pComp doesn’t look too horrible right now:

I’ve started to get this tree thing off the ground, first with a sketch:

Which is based largely on these two tree ideas:

[gem tree] and [wire bonsai]

Well, it looks pretty in code anyway.

This was the orignial idea:

And the tree’s code is a-comin’ along. This is the Arduino code for my (admittedly randomly picked) colors:

int ledPin = 11; // LED connected to digital pin 13
int val = 0;
int ledR = 9; // PWM pin that the LED is on. n.b. PWM 0 is on digital pin 9
int ledG = 10; // PWM pin that the LED is on. n.b. PWM 0 is on digital pin 10
int ledB = 11; // PWM pin that the LED is on. n.b. PWM 0 is on digital pin 11

void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
Serial.begin(9600);
}

void loop(){
val = Serial.read();

if (val == ‘A’) {
analogWrite(ledR, (255)); // PWM the LED with the pot value
analogWrite(ledG, (100)); // PWM the LED with the pot value
analogWrite(ledB, (100)); // PWM the LED with the pot value
}

if (val == ‘B’) {
analogWrite(ledR, (55)); // PWM the LED with the pot value
analogWrite(ledG, (255)); // PWM the LED with the pot value
analogWrite(ledB, (255)); // PWM the LED with the pot value
}

if (val == ‘C’) {
analogWrite(ledR, (100)); // PWM the LED with the pot value
analogWrite(ledG, (255)); // PWM the LED with the pot value
analogWrite(ledB, (155)); // PWM the LED with the pot value
}

if (val == ‘D’) {
analogWrite(ledR, (100)); // PWM the LED with the pot value
analogWrite(ledG, (150)); // PWM the LED with the pot value
analogWrite(ledB, (100)); // PWM the LED with the pot value
}

if (val == ‘E’) {
analogWrite(ledR, (55)); // PWM the LED with the pot value
analogWrite(ledG, (250)); // PWM the LED with the pot value
analogWrite(ledB, (100)); // PWM the LED with the pot value
}

if (val == ‘E’) {
analogWrite(ledR, (55)); // PWM the LED with the pot value
analogWrite(ledG, (97)); // PWM the LED with the pot value
analogWrite(ledB, (255)); // PWM the LED with the pot value
}

if (val == ‘a’) {

digitalWrite(ledR, LOW); // sets the LED off
digitalWrite(ledG, LOW); // sets the LED off
digitalWrite(ledB, LOW); // sets the LED off
}
}

This much is good…

[movie!]

Post a Comment

Your email is never published nor shared. Required fields are marked *