Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SoftPWM.h>
- #include <SoftPWM_timer.h>
- /*
- sftPWM with
- */
- void setup()
- {
- // Initialize Serial
- Serial.begin(9600); // set up Serial at 9600 bps
- // Initialize SoftPWM
- SoftPWMBegin();
- // Create and set pins for PWM use and turn them off
- for (int a=22; a<=52; a++){
- SoftPWMSet(a, 0);
- }
- }
- // Initialize Loop counter
- int i = 0;
- // Set array to store the 31 values from the serial port
- int incomingByte[31];
- void loop()
- { // 31 channels are coming in to the Arduino
- if (Serial.available() >= 31) {
- // read the oldest byte in the serial buffer:
- for (int i=0; i<31; i++) {
- // read each byte
- incomingByte[i] = Serial.read();
- }
- SoftPWMSet(22, incomingByte[0]); // Write current values to LED pins
- SoftPWMSet(23, incomingByte[1]); // Write current values to LED pins
- SoftPWMSet(24, incomingByte[2]); // Write current values to LED pins
- SoftPWMSet(25, incomingByte[3]); // Write current values to LED pins
- SoftPWMSet(26, incomingByte[4]); // Write current values to LED pins
- SoftPWMSet(27, incomingByte[5]); // Write current values to LED pins
- SoftPWMSet(28, incomingByte[6]); // Write current values to LED pins
- SoftPWMSet(29, incomingByte[7]); // Write current values to LED pins
- SoftPWMSet(30, incomingByte[8]); // Write current values to LED pins
- SoftPWMSet(31, incomingByte[9]); // Write current values to LED pins
- SoftPWMSet(32, incomingByte[10]); // Write current values to LED pins
- SoftPWMSet(33, incomingByte[11]); // Write current values to LED pins
- SoftPWMSet(34, incomingByte[12]); // Write current values to LED pins
- SoftPWMSet(35, incomingByte[13]); // Write current values to LED pins
- SoftPWMSet(36, incomingByte[14]); // Write current values to LED pins
- SoftPWMSet(37, incomingByte[15]); // Write current values to LED pins
- SoftPWMSet(38, incomingByte[16]); // Write current values to LED pins
- SoftPWMSet(39, incomingByte[17]); // Write current values to LED pins
- SoftPWMSet(40, incomingByte[18]); // Write current values to LED pins
- SoftPWMSet(41, incomingByte[19]); // Write current values to LED pins
- SoftPWMSet(42, incomingByte[20]); // Write current values to LED pins
- SoftPWMSet(43, incomingByte[21]);
- SoftPWMSet(44, incomingByte[22]);
- SoftPWMSet(45, incomingByte[23]);
- SoftPWMSet(46, incomingByte[24]);
- SoftPWMSet(47, incomingByte[25]);
- SoftPWMSet(48, incomingByte[26]);
- SoftPWMSet(49, incomingByte[27]);
- SoftPWMSet(50, incomingByte[28]);
- SoftPWMSet(51, incomingByte[29]);
- SoftPWMSet(52, incomingByte[30]);
- }}
Advertisement
Add Comment
Please, Sign In to add comment