Reflection
- To begin this assignment I struggled to get my laptop to recognize the flora board. I grew frustrated rather quickly and started to panic, thinking my laptop was not new enough to be able to run correctly for the assignment. At one point I decided that it was not going to work and tried 3 different computers in my household before I finally went back to my laptop and got it to work with the help of chatGPT. Without the AI, I would not have been able to complete the assignment. I found great success in using chatGPT to assist me in understanding the code by breaking it down step by step. It explained the purpose of each part of the code, its functionality, and how it related to the desired output. It simplified the errors in the code that I posted as well. In the assignment code given to us, there were stray characters and incorrect delay values. The AI guided me on how to correct these issues, which helped me build a code that would run correctly. It offered suggestions for improving and optimizing the code. For example, a corrected version of the code to achieve the 2-second pauses between colors, which aligned with the desired sequence. AI is an absolutely incredible tool to use, especially in the area of coding. I was amazed as to how it spit out the corrected code that I needed. While I still had to go back into the code and change things around myself, without the AI I would have been extremely lost. Even when there was an error put out and I had the color red all over my code, I asked the AI why the copy and pasted code was not uploading. It told me there could be an issue with the copy and paste feature, so I had to delete and input the code manually and that fixed all of my error issues. The AI tool was extremely helpful throughout the entire process.
Fixing the Code
- Input the code into chatGPT, it tells me that to correct the errors within the code, I needed toadd the missing semicolons and ensure that the delay values in the comments match the actual delay values in the code
- Went to the code and adjusted the delay values as well as adding missing semicolons, also had to delete and redo each indiviual line based on the copy and paste issue
- Fixing the delay value to ensure there was the correct time in between blinks
Final Code
/*
Written by Brandon Watson for the AI & Arduino Coding Assignment in CTCH 110 Fall 2023 at the University of Regina.
The following code is designed to blink the onboard led on an Adafruit FLORA in a certain sequence. The sequence is:
RED – for 1 second
OFF – for 2 seconds
Green – for 1 second
OFF – for 2 seconds
Blue – for 1 second
OFF – for 2 seconds
This sequence should repeat indefinitely.
*/
#include <Adafruit_NeoPixel.h> // Include the NeoPixel library
#define PIN 17 // Pick the pin on the Circuit Playground that the LED is connected to (in this case, pin 17)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin(); // Initialize the LED pixel
strip.show(); // Initialize the pixel to ‘off’
}
void loop() {
// first number = pixel number | second number = red brightness (0 – 255) | third number = green brightness (0 – 255) | fourth number = blue brightness (0 – 255)
// Example: strip.setPixelColor(pixel 1, Red, Green, Blue)
// Pixel 1 should be ‘0’ because the count starts at 0
strip.setPixelColor(0, 255, 0, 100);
strip.show();
delay(1000); //Delay for 1000 miliseconds
strip.setPixelColor(0, 0, 0, 0);
strip.show();
delay(2000); //Delay for 2000 miliseconds
strip.setPixelColor(0, 0, 255, 0);
strip.show();
delay(1000); //Delay for 1000 miliseconds
strip.setPixelColor(0, 0, 0, 0);
strip.show();
delay(2000); //Delay for 2000 miliseconds
strip.setPixelColor(0, 0, 0, 255);
strip.show();
delay(1000); //Delay for 1000 miliseconds
strip.setPixelColor(0, 0, 0, 0);
strip.show();
delay(2000); //Delay for 2000 miliseconds
}
Leave a Reply