Week Eight: Microcontroller Programming

Aw, dang. I programmed the device. Most important lesson: get all of the details right and the tools work and work. One mistake is fail and fail. Commas and semicolons look similar, but oh boy different meanings.

Here I am with copious notes, and a sketchy history of code in several projects. I installed the compiler package for the ARV family of microcontrollers, and XCode, and BBedit’s free version. All of the code was written in XCode. I did not figure out the higher order functions of XCode on macOSX which would, no doubt, have included version control. I read the AT44A data sheet to about 40 pages in, at which point I could see which functionality I could ignore for now. Also I was nodding off.

I made my circuit board from Week Six flash when a button is pressed. Here is the code, brutally unformatted with minimal commenting.

The bit bump OR thingami did not make sense at first, so in order to get logical ones and zeros to the appropriate pins, I wrote a subroutine called showPips() to write all the bits in 0bxxxxxxxx format. I used the same format to write pinwheel(), as a dazzler. Crazy waste of space, which I can tighten up in the next version. However, it works, and is visual.

Bounced around Google looking for a {1..6} random function, which of course was based on rand() in stdlib.h. A subroutine from Yale CS gave me my pseudo-random number, and a counter variable in the main while loop is my dubious source of entropy.

The main() loop uses a while(true) to run, and a counter feeds srand() a seed, and sets a variable to 0 if the switch is pressed.  The second while() loop tests for the switch press, and runs a routine if true.

The routine shows 50 random numbers between 0 and 7 very quickly, then settles on value1 {1..6} for a short time. A quick count up from 0 to 7 settles on value2{1..6}.  Later code tests the sum of the two values is 7, the pinwheel function is called (not shown in videos).

More work to do: better random seed; program the rest of the game, Craps, onto the board; remake the board for looks and add 2 x CR2016 for power, lose the ISP pins.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>