Guest User

Untitled

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