Randomly Generated Rainbow

Table of Contents

A single LED that flashes on and off, is cool and all, but a rainbow is even cooler. If you haven't seen the previous post, check it out.

1 Required Hardware

  • 1X ARDUINO UNO (+ PROGRAMMING ACCESSORIES)
  • 3X RED RED BROWN RESISTORS (22K?)

2 Assembly

DPIO.6 -> RESISTOR_A -> LED_3 -+
DPIO.5 -> RESISTOR_B -> LED_2 -+ –----
DPIO.3 -> RESISTOR_C -> LED_1 -+   ,'
				   |
			LED_GND <--+

3 uLisp Code Via Serial Connection

# your /dev/ttyACM* device may be different. lsusb for specificity.
tio -b9600 /dev/ttyACM0

;; RGB now
(defvar rp 3)
(defvar gp 5)
(defvar bp 6)

(defvar dly 2) 


(defun stp ()
  (pinmode rp t)
  (pinmode gp t)
  (pinmode bp t)) 


(defun red (n)
  (analogwrite rp n))

(defun gre (n)
  (analogwrite gp n))

(defun blu (n)
  (analogwrite bp n))

(defun rgb (a b c)
  (red a)
  (gre b)
  (blu c))

(defun off ()
  (red 255)
  (gre 255)
  (blu 255))


(defun on ()
  (red 0)
  (gre 0)
  (blu 0))

(defun ron ()
  (red (random 255))
  (gre (random 255))
  (blu (random 255)))


(defun rxn ()
  (red (logxor 255 (random 255)))
  (gre (logxor 255 (random 255)))
  (blu (logxor 255 (random 255))))


(defvar max 256)
(defvar dll 500)

(dotimes (x 4)
  (rxn)
  (delay 800)
  (ron)
  (delay 800)
  (off))

Author: me

Created: 2020-02-12 Wed 13:03

Validate