Hi
i made a projBox with 6 knobs, 6 switches and 6 leds and one Arduino Uno. I tried it with a sketch and works
perfectly. I've uploaded on the board the Standard Firmata, and i make a sketch with processing for read the value from the arduino. But when i've tried to write an analog value to my PWM pin for light the led, the sketch don't write anything and the led don't light. instead the digitalWrite work perfectly. also the digitalRead set to my switch pin don't read the value of the switch. Why?? I post the processing code that i wrote
import processing.serial.*; import cc.arduino.*;
Arduino arduino;
// Arrays of the pins connected to the Arduino int[] sw = {2, 4, 7, 8, 12}; //Switch (analog pins) int[] kn = {0, 1, 2, 3, 4, 5}; //Knob (digital pins) int[] led = {3, 5, 6, 9, 10, 11}; //Led (PWM pins)
void setup() { size(1000, 500); smooth(); //Arduino arduino = new Arduino(this, Arduino.list()[1], 57600); for(int i = 0; i < sw.length; i++) { arduino.pinMode(sw[i], Arduino.INPUT); arduino.digitalWrite(sw[i], Arduino.HIGH); } arduino.pinMode(13, Arduino.INPUT); for(int i = 0; i < led.length; i++) { arduino.pinMode(led[i], Arduino.OUTPUT); } }
void draw() { ledPwm();
print(arduino.digitalRead(4)); }
void ledPwm() { int temp; for(int i = 0; i < kn.length; i++) { temp = floor(map(arduino.analogRead(kn[i]), 0, 1023, 0, 255)); print(temp + " "); arduino.analogWrite(led[i], temp); }