千枝落星河 果子非卖品
关注数: 572 粉丝数: 458 发帖数: 7,843 关注贴吧数: 112
求助下?循环语句 有问题? /* * Arduino interface for the use of WS2812 strip LEDs * Uses Adalight protocol and is compatible with Boblight, Prismatik etc... * "Magic Word" for synchronisation is 'Ada' followed by LED High, Low and Checksum * @author: Wifsimster <[email protected]> * @library: FastLED v3.001 * @date: 11/22/2015 */ #include "FastLED.h" #define NUM_LEDS 92 /你的灯珠数量 #define DATA_PIN 6 /输出针脚 // Baudrate, higher rate allows faster refresh rate and more LEDs (defined in /etc/boblight.conf) #define serialRate 115200 // Adalight sends a "Magic Word" (defined in /etc/boblight.conf) before sending the pixel data uint8_t prefix[] = {'A', 'd', 'a'}, hi, lo, chk, i; // Initialise LED-array CRGB leds[NUM_LEDS]; void setup() { // Use NEOPIXEL to keep true colors FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS); // Initial RGB flash LEDS.showColor(CRGB(255, 0, 0)); delay(500); LEDS.showColor(CRGB(0, 255, 0)); delay(500); LEDS.showColor(CRGB(0, 0, 255)); delay(500); LEDS.showColor(CRGB(0, 0, 0)); Serial.begin(serialRate); // Send "Magic Word" string to host Serial.print("Ada\n"); } void loop() { // Wait for first byte of Magic Word for(i = 0; i < sizeof prefix; ++i) { waitLoop: while (!Serial.available()) ;; // Check next byte in Magic Word if(prefix[i] == Serial.read()) continue; // otherwise, start over i = 0; goto waitLoop; } // Hi, Lo, Checksum while (!Serial.available()) ;; hi=Serial.read(); while (!Serial.available()) ;; lo=Serial.read(); while (!Serial.available()) ;; chk=Serial.read(); // If checksum does not match go back to wait if (chk != (hi ^ lo ^ 0x55)) { i=0; goto waitLoop; } memset(leds, 0, NUM_LEDS * sizeof(struct CRGB)); // Read the transmission data and set LED values for (uint8_t i = 0; i < NUM_LEDS; i++) { byte r, g, b; while(!Serial.available()); r = Serial.read(); while(!Serial.available()); g = Serial.read(); while(!Serial.available()); b = Serial.read(); leds[i].r = r; leds[i].g = g; leds[i].b = b; } // Shows new values FastLED.show(); } —————————————————————————————————————————— 错误信息 Arduino:1.8.9 (Windows 10), 开发板:"Arduino Nano, ATmega328P (Old Bootloader)" sketch_apr21a:20:1: error: stray '\344' in program CRGB leds[NUM_LEDS]; ^ sketch_apr21a:20:1: error: stray '\275' in program sketch_apr21a:20:1: error: stray '\240' in program sketch_apr21a:20:1: error: stray '\347' in program sketch_apr21a:20:1: error: stray '\232' in program sketch_apr21a:20:1: error: stray '\204' in program sketch_apr21a:20:1: error: stray '\347' in program sketch_apr21a:20:1: error: stray '\201' in program sketch_apr21a:20:1: error: stray '\257' in program sketch_apr21a:20:1: error: stray '\347' in program sketch_apr21a:20:1: error: stray '\217' in program sketch_apr21a:20:1: error: stray '\240' in program sketch_apr21a:20:1: error: stray '\346' in program sketch_apr21a:20:1: error: stray '\225' in program sketch_apr21a:20:1: error: stray '\260' in program sketch_apr21a:20:1: error: stray '\351' in program sketch_apr21a:20:1: error: stray '\207' in program sketch_apr21a:20:1: error: stray '\217' in program sketch_apr21a:24:3: error: stray '\350' in program FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS); ^ sketch_apr21a:24:3: error: stray '\276' in program sketch_apr21a:24:3: error: stray '\223' in program sketch_apr21a:24:3: error: stray '\345' in program sketch_apr21a:24:3: error: stray '\207' in program sketch_apr21a:24:3: error: stray '\272' in program sketch_apr21a:24:3: error: stray '\351' in program sketch_apr21a:24:3: error: stray '\222' in program sketch_apr21a:24:3: error: stray '\210' in program sketch_apr21a:24:3: error: stray '\350' in program sketch_apr21a:24:3: error: stray '\204' in program sketch_apr21a:24:3: error: stray '\232' in program sketch_apr21a:24:3: error: stray '\344' in program sketch_apr21a:24:3: error: stray '\275' in program sketch_apr21a:24:3: error: stray '\240' in program sketch_apr21a:24:3: error: stray '\347' in program sketch_apr21a:24:3: error: stray '\232' in program sketch_apr21a:24:3: error: stray '\204' in program sketch_apr21a:24:3: error: stray '\347' in program sketch_apr21a:24:3: error: stray '\201' in program sketch_apr21a:24:3: error: stray '\257' in program sketch_apr21a:24:3: error: stray '\347' in program sketch_apr21a:24:3: error: stray '\217' in program sketch_apr21a:24:3: error: stray '\240' in program sketch_apr21a:24:3: error: stray '\346' in program sketch_apr21a:24:3: error: stray '\225' in program sketch_apr21a:24:3: error: stray '\260' in program sketch_apr21a:24:3: error: stray '\351' in program sketch_apr21a:24:3: error: stray '\207' in program sketch_apr21a:24:3: error: stray '\217' in program sketch_apr21a:65:3: error: stray '\344' in program memset(leds, 0, NUM_LEDS * sizeof(struct CRGB)); ^ sketch_apr21a:65:3: error: stray '\275' in program sketch_apr21a:65:3: error: stray '\240' in program sketch_apr21a:65:3: error: stray '\347' in program sketch_apr21a:65:3: error: stray '\232' in program sketch_apr21a:65:3: error: stray '\204' in program sketch_apr21a:65:3: error: stray '\347' in program sketch_apr21a:65:3: error: stray '\201' in program sketch_apr21a:65:3: error: stray '\257' in program sketch_apr21a:65:3: error: stray '\347' in program sketch_apr21a:65:3: error: stray '\217' in program sketch_apr21a:65:3: error: stray '\240' in program sketch_apr21a:65:3: error: stray '\346' in program sketch_apr21a:65:3: error: stray '\225' in program sketch_apr21a:65:3: error: stray '\260' in program sketch_apr21a:65:3: error: stray '\351' in program sketch_apr21a:65:3: error: stray '\207' in program sketch_apr21a:65:3: error: stray '\217' in program sketch_apr21a:67:3: error: stray '\344' in program for (uint8_t i = 0; i < NUM_LEDS; i++) { ^ sketch_apr21a:67:3: error: stray '\275' in program sketch_apr21a:67:3: error: stray '\240' in program sketch_apr21a:67:3: error: stray '\347' in program sketch_apr21a:67:3: error: stray '\232' in program sketch_apr21a:67:3: error: stray '\204' in program sketch_apr21a:67:3: error: stray '\347' in program sketch_apr21a:67:3: error: stray '\201' in program sketch_apr21a:67:3: error: stray '\257' in program sketch_apr21a:67:3: error: stray '\347' in program sketch_apr21a:67:3: error: stray '\217' in program sketch_apr21a:67:3: error: stray '\240' in program sketch_apr21a:67:3: error: stray '\346' in program sketch_apr21a:67:3: error: stray '\225' in program sketch_apr21a:67:3: error: stray '\260' in program sketch_apr21a:67:3: error: stray '\351' in program sketch_apr21a:67:3: error: stray '\207' in program sketch_apr21a:67:3: error: stray '\217' in program In file included from C:\Users\biyang\Desktop\sketch_apr21a\sketch_apr21a.ino:9:0: C:\Users\biyang\Documents\Arduino\libraries\FastLED/FastLED.h:14:21: note: #pragma message: FastLED version 3.002.006 # pragma message "FastLED version 3.002.006" ^ sketch_apr21a:20:19: error: expected primary-expression before ']' token CRGB leds[NUM_LEDS]; ^ C:\Users\biyang\Desktop\sketch_apr21a\sketch_apr21a.ino: In function 'void setup()': sketch_apr21a:24:11: error: parse error in template argument list FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS); ^ sketch_apr21a:24:39: error: 'leds' was not declared in this scope FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS); ^ sketch_apr21a:24:53: error: expected primary-expression before ')' token FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS); ^ C:\Users\biyang\Desktop\sketch_apr21a\sketch_apr21a.ino: In function 'void loop()': sketch_apr21a:65:10: error: 'leds' was not declared in this scope memset(leds, 0, NUM_LEDS * sizeof(struct CRGB)); ^ sketch_apr21a:65:48: error: invalid type argument of unary '*' (have 'unsigned int') memset(leds, 0, NUM_LEDS * sizeof(struct CRGB)); ^ sketch_apr21a:67:35: error: expected primary-expression before ';' token for (uint8_t i = 0; i < NUM_LEDS; i++) { ^ exit status 1 stray '\344' in program 在文件 -> 首选项开启 “编译过程中显示详细输出”选项 这份报告会包含更多信息。
1 下一页