top of page
jessicadai1018

Assignment 6

The primary objective of the given code is to control the behavior of three LEDs using teachable machine inputs.


  • LED Blinking on Byte 1:

When the byte 1 is received, all the LEDs connected to the declared pins (ledPin1, ledPin2, and ledPin3) are set to blink. This is accomplished by turning the LED on (HIGH state), waiting for a short period, turning the LED off (LOW state), and then waiting again, thus creating the blinking effect.

  • LED Dimming on Byte 2:

Upon receiving the byte 2, the LED associated with ledPin2 is set to fade in and out, creating a dimming effect. This dimming is achieved through the PWM (Pulse Width Modulation) capabilities of the microcontroller. Essentially, the analogWrite() function modulates the duty cycle of a digital pulse to control the brightness of the LED. The brightness is first incremented until it reaches its maximum, after which it is decremented, creating a fade-in and fade-out effect.

  • LEDs Lit on Byte 3:

If the byte 3 is received, all the LEDs are turned on and maintained in a constantly lit state.



1 view0 comments

Recent Posts

See All

Comentários


bottom of page