{\rtf1\ansi\ansicpg936\cocoartf2512 \cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fmodern\fcharset0 CourierNewPSMT;} {\colortbl;\red255\green255\blue255;\red42\green55\blue62;\red231\green231\blue231;} {\*\expandedcolortbl;;\cssrgb\c21569\c27843\c30980;\cssrgb\c92549\c92549\c92549\c50196;} \paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0 \deftab720 \pard\pardeftab720\partightenfactor0 \f0\fs27\fsmilli13600 \cf2 \cb3 \expnd0\expndtw0\kerning0 #define RED_PIN 9\ #define BLUE_PIN 10\ #define GREEN_PIN 11\ \ #define NUM_BYTES 3\ \ char led_color[NUM_BYTES] = \{0, \};\ unsigned char R, G, B;\ \ void RGB(unsigned char r, unsigned char g, unsigned char b) \{\ analogWrite(RED_PIN, r); \ analogWrite(BLUE_PIN, b); \ analogWrite(GREEN_PIN, g);\ \}\ \ void setup() \{\ // put setup code here, to run once:\ Serial.begin(9600); //Sets the data rate in bits per second (baud) for serial data transmission.\ \}\ \ void loop() \{\ // put main code here, to run repeatedly: \ \ while(Serial.available() == 0); // Get the number of bytes (characters) available for reading from the serial port. This is data that\'92s already arrived and stored in the serial receive buffer (which holds 64 bytes).\ \ Serial.readBytes(led_color, NUM_BYTES);//reads characters from the serial port into a buffer. \ \ R = (unsigned char)(led_color[0]);\ G = (unsigned char)(led_color[1]);\ B = (unsigned char)(led_color[2]);\ \ RGB(R, G, B);\ \ \}}