POI light toy

At the moment I am teaching a class in collage where the students use CC430 microcontrollers to learn the basics of wireless sensor networks. This class is more like a practical training with a few lessons to teach the theories behind it and explain some of the peripherals of the controller and the RF stuff. The course is structured in 3 parts and each part consists of 3 lessons. Bildschirmfoto 2015-03-31 um 12.03.32

The problem with that is, some students are faster then I expected with finishing the tasks for part 1. So I had to come up with an extra task for part 1. In the task of part 1, the students got taught how to use Flash memory, the UART interface and the SPI bus. The board which is used in the practical training happens to have an SPI port expander with 8 LEDs on it. Thus it is perfectly suitable for a POI light toy. Watch the YouTube Video if you want to see some of this devices in action.

Bildschirmfoto 2015-03-31 um 12.09.57

This type of art works by capturing the movement of the leds with a camera set to long exposure. While moving the led device, the led patterns will change and draw some colors or text. In my case I implemented a simple „Hello World!“ text to prove the concept.

IMG_1703

The job for the students is to write some code which can read a text from the serial interface, store that data in flash memory and show the text on startup via the leds on the port expander. So it is a combination of all the newly acquired skills in one project.

Provided for that will be a 5×8 character array in form of a .h file and a simple Spi library for sending out data. Hopefully it takes at least one course date (~3 hours) for the students to figure out how to do that, to keep them busy till part 2 of the course.

As the code is really short I will post it right here. You will find the project as always on Github

// POI
#include "drivers/spi.h"
#include "defines.h"
#include "font.c"</code>

char msg[] = "Hello World! ";
uint8_t len = 14;

void printChar(char c);

void send_Byte(char add, char data){
  SPI_OUT_PORT &amp;= ~CS_PIN;
  spi_send(0x40);
  spi_send(add);
  spi_send(data);
  SPI_OUT_PORT |= CS_PIN;
}

void main(void){
  WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
  initSPI();

  send_Byte(0x01, 0x00);

  while(1){
    int i=0;
    for(i=0;i&lt;len;i++)
      printChar(msg[i]);
  }
}

void printChar(char c){
  int i=0;
  for(i=0;i&lt;5;i++){
    int line = font[(c*5)+i];
    send_Byte(0x13, line);
    __delay_cycles(500);
  }
}

Github: POI_light_toy

Advertisements

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Abmelden / Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s