Back to Parent

Outcome



Intention

I haven't touched an Arduino board in a long time. Through this practice, I've managed to recapture some of the old feelings, and I'm excited to work with Photon hardware. It's similar to Arduino but can connect to the online platform with itself to manipulate, which is really cool!

Process

1/First Sketch

Exercise 1

Modify the program to Blink on and off every 3 seconds.

1 01 02.thumb
Show Advanced Options
Show Advanced Options

Exercise 2

Change the program to blink on and off 5 times then stop for 3 seconds. Each blink should be 0.5s.

Show Advanced Options

Exercise 3
Add a second LED to the circuit. Program the LED’s to alternate blinks i.e. when LED 1 turns on, LED 2 turns off, then when LED 2 turns on, LED 1 turns off.

Img 5536.jpg.thumb
Show Advanced Options
Show Advanced Options

Extra Exploration 3-1

This is an extra exploration of the 2 LED circuit: This code controls two LEDs, red and orange, to alternately blink with changing speeds. The main loop of the program cycles through functions to speed up and then slow down the blinking. The speedUp function gradually decreases the delay between the blinking from a longer to a shorter interval, making the LEDs blink faster. Conversely, the slowDown function increases the delay, making the LEDs blink slower. This creates a visual effect of accelerating and decelerating light pulses between the two LEDs.

Show Advanced Options

2/Connected LED

Exercise 1

Modify the cloud function to blink the LED 3 times after it is called.

Show Advanced Options

Exercise 2

Pass the number of times user would like it to blink. Set the function to blink that number of times. Finally once it has completed all of the blinking it should turn the LED off.

Show Advanced Options

Exercise 3

Add a second LED to the circuit. Change the program and cloud function to allow you to control both LEDs remotely.

Due to the instructions is sort of brief here, I was wondering about how exactly to construct the blinking mechanism. Initially, I planned to use the '+' and '-' keys on the keyboard to control the alternating blinking speed of the two LEDs. However, after attempting this, I realized that user input was only prompted at the start of the program. Consequently, I opted to allow the user to input the blinking interval as a way to alternate the LED flashing.

Show Advanced Options

But when users enter something that's not a number, the LEDs stop working. So, I'm planning to do something to keep them working in a default mode and send out a signal to let users know there's something wrong with their input.


*An iteration:

In the refined version of my code, I introduced a new function, parseBlinkInterval, which robustly converts the incoming string to an integer and validates it. This function uses strtol for conversion and checks if the entire string was valid for conversion. If not, it returns -1 as an error indicator.

Back in the ledControl function, I added a check for the -1 error code from parseBlinkInterval. If an invalid interval is detected, I default the blinking to a standard delay of 1000 milliseconds as a fallback, ensuring the program remains operational even with incorrect input.

Show Advanced Options
Rgb.thumb
Show Advanced Options
Show Advanced Options

Reflection / Next Steps

  • Particle document really helps! But there are many unfamiliar technical concepts and terms so I need more time to digest it.
  • ChatGPT is also a good assistant in checking the syntax etc. But sometimes it only provides code that seems can run but turns out not that obvious or proper when running in the board. So me as a designer must shoulder the responsibility to observe, hand-on adjust, and iterate the overall design.
  • The next steps may be:
    • dive into document
    • explore how to combine user input on a screen and tangible user input or sensor input as a system to manipulate the output.
Drop files here or click to select

You can upload files of up to 20MB using this form.