Getting started for Arduino IDE users - Programming CW01 (ESP8266) to flash the LED

Getting started for Arduino IDE users - Programming CW01 (ESP8266) to flash the LED

Hi, here is the second in our blog series for Arduino IDE users. Last time we covered Connecting and Coding the ESP8266 (xChip CW01) with the IP01 programming xChip. This time we programme the CW01 to drive the Red, Green, and Blue LEDs.

Please see our Getting Started page for a full list of resources supporting Arduino IDE users.

Contents
  1. What you need
  2. Installations
  3. What to do
  4. When things don't work as expected
  5. What to do next
  6. References
  7. Code file

 

1. What you need

  • the IP01 and CW01, set up as per 'XinaBox IP01 and CW01 Setup' 
                            
   IP01 - switches                                 IP01 - solder pads
  • the Arduino Blog 2 Code (at the bottom of this blog)

 

2. Installations

  • see previous blog on IP01 and CW01 Setup

 

3. To do
  • set the switches on the IP01 so that the CW01 can be programmed (flashed)
    • the first version of the IP01 has 2 small switches - make sure SW1 is set to position B, and SW2 is set to the DCE position
                       
                                         top view                                    side view   
    • the second version of the IP01 does not have switches
  • set the programmer to "Arduino as ISP" in the Tools->Programmer menu

            

  • copy the code at the bottom of this blog into the Arduino IDE 
  • click the 'Verify' button or select Sketch->Verify/Compile or type CTRL+R, make sure no errors are reported, and that 'Done compiling' is reported

                               

  • save the file using File->Save or CTRL+S if you have made any modifications to the code
  • once the compile is successful, click the 'Upload' button or select Sketch->Upload or type CTRL+U, and make sure 'Done uploading' is reported

                              

  • observe the LEDs on the CW01, these should continuously cycle from Red to Green to Blue and back to Red

                              

  • select Tools->Serial Monitor to observe to messages output by the Serial.print("...") statements

            

 

4. When things don't work as expected

    • although every effort has been made to verify the Sketch code and the steps presented here, things can go wrong
      • the first thing to do is ensure that the steps above have been followed
      • check that the switches on the IP01 board are in the correct positions
      • check that the code has not accidently been modified by an unintentional keystroke
      • try more than once, and if nothing works as presented here, revert back to 'XinaBox IP01 and CW01 Setup' and ensure that your setup was successful before moving to the next step

     

    5. What to do next
      • Read and understand the code in this example, and move on to our next blog, which will be on connecting the CW01 to a WiFi endpoint.

       

      6. References

         

        7. Code file

         /*****************************************************************************
            This Sketch is an example for the XinaBox CW01 ESP8266 Board
            It demonstrates how to drive the CW01 LEDs
            You can buy these devices on our store!
             -----> https://xinabox.cc/CW01/
            Currently Supported on the following ☒CHIPs:
            - CW01
        *****************************************************************************/
        
        /************************** Library Includes ********************************/
        #include 
        
        /**************************** SYSTEM DEFINES *********************************/
        #define RED 12
        #define GREEN 13
        #define BLUE 5
        
        /***************************** Sketch Code ***********************************/
        void setup() {
          // Start the Serial Monitor
          Serial.begin(115200);
          
          // set pins as outputs
          pinMode(RED, OUTPUT);
          pinMode(GREEN, OUTPUT);
          pinMode(BLUE, OUTPUT);
        }
        
        void loop() {
          // cycle the LEDs forever
          
          // RED
          Serial.println("RED");
          digitalWrite(RED, HIGH);
          delay(500);
          digitalWrite(RED, LOW);
          
          // GREEN
          Serial.println("GREEN");
          digitalWrite(GREEN, HIGH);
          delay(500);
          digitalWrite(GREEN, LOW);
           
          // BLUE
          Serial.println("BLUE");
          digitalWrite(BLUE, HIGH);
          delay(500);
          digitalWrite(BLUE, LOW);
        }
         
         
        ----- 
        Please see our getting started page for a full list of resources supporting Arduino IDE users, and the XK51 Arduino Zero Compatible Kit to build devices in minutes.
         
        XinaBox is a rapid electronics development solution for developing, making products and learning. Without soldering, wiring, breadboarding, or hardware knowledge, the developer can assemble a circuit in a matter of minutes, and get straight to coding in their choice of language.
        Previous article Getting Started for Arduino users - Connecting CW01 (ESP8266) to WiFi
        Next article Win a fantastic XinaBox IoT Starter Kit, powered by Zerynth, with our competition in Electronics Weekly

        Leave a comment

        Comments must be approved before appearing

        * Required fields