• Here's some code...

    bret.wiebe08/16/2015 at 00:52 0 comments

    Definitely not elegant or optimal, but here's what is presently running this thing:

    #include <SevenSeg.h>

    #include <Wire.h>

    #include <Time.h>

    #include <DS1307RTC.h>

    #include <Adafruit_Sensor.h>

    #include <Adafruit_LSM303_U.h>

    SevenSeg disp(10,12,7,8,9,11,A2);

    const int numOfDigits=4;

    int digitPins[numOfDigits]={5,4,2,6};

    volatile int indexMode = 0;

    char* nounAZ[] = {"lamp", "desk", " car", " dog", " cat", "door", "bike", "shoe", "tree", "shed", "fork", " tea", "hill", " job", "head", "food", " cup", "cafe", " dad", " mom"};

    char* verbAZ[] = {" is", " was", " are", " ate", "goes", "runs", "eats", "wins", "sees", "gets", "puts", "cuts", " had"};

    char* adjAZ[] = {" big", "blue", "tiny", " red", " bad", "good", "easy", " wee", "huge", " mad", " sad", "glad", " rad", "near", " far", " low", "high", "wide", "thin", " hot", "cold", "cool", "warm"};

    int poem1[] = {8, 1, 2, 3, 1, 1, 2, 3, 1};

    int poemLength = poem1[0] +1;

    Adafruit_LSM303_Mag_Unified mag = Adafruit_LSM303_Mag_Unified(12345);

    void setup() {

    disp.setDigitPins(numOfDigits,digitPins);

    disp.setDPPin(13);

    pinMode(3, INPUT);

    attachInterrupt(1, changeMode, FALLING);

    if(!mag.begin())

    }

    // the loop function runs over and over again forever

    void loop() {

    switch (indexMode) {

    case 0:

    for (int pmode=1; pmode<150; pmode++) {

    disp.write("poem");

    delay(10);

    }

    displayPoem();

    break;

    case 1:

    for (int tmode=1; tmode<150; tmode++) {

    disp.write("time");

    delay(10);

    }

    printTime();

    break;

    case 2:

    for (int dmode=1; dmode<150; dmode++) {

    disp.write("dirn");

    delay(10);

    }

    printDirn();

    break;

    }

    }

    void displayPoem(){

    int i = 1;

    int poemLength = poem1[0] + 1;

    while (i < poemLength) {

    int poemIndex = poem1[i];

    if (poemIndex == 1)

    {

    printNoun();

    }

    else if (poemIndex == 2)

    {

    printVerb();

    }

    else if (poemIndex == 3)

    {

    printAdj();

    }

    else

    {

    Serial.println("oops");

    }

    i++;

    }

    for (int j=0; j<=129; j++) {

    disp.write("fini");

    delay(5);

    }

    }

    void printNoun(){

    randomSeed(analogRead(1));

    int numTD;

    numTD = random(19);

    delay(150);

    for (int b=0; b <=100; b++){

    disp.write(nounAZ[numTD]);

    delay(5);

    }

    delay(500);

    }

    void printVerb(){

    randomSeed(analogRead(1));

    int numTD;

    numTD = random(12);

    delay(150);

    for (int b=0; b <=100; b++){

    disp.write(verbAZ[numTD]);

    delay(5);

    }

    delay(500);

    }

    void printAdj(){

    randomSeed(analogRead(1));

    int numTD;

    numTD = random(22);

    delay(150);

    for (int b=0; b <=100; b++){

    disp.write(adjAZ[numTD]);

    delay(5);

    }

    delay(500);

    }

    void printTime(){

    tmElements_t tm;

    if (RTC.read(tm)) {

    }

    //delay(1000);

    int hours = tm.Hour;

    int minutes = tm.Minute;

    for (int j=0; j<=333; j++) {

    disp.writeClock(hours,minutes);

    }

    delay(5);

    }

    void printDirn(){

    //disp.write("dirn");

    /* Get a new sensor event */

    sensors_event_t event;

    mag.getEvent(&event);

    float Pi = 3.14159;

    // Calculate the angle of the vector y,x

    float heading = (atan2(event.magnetic.y,event.magnetic.x) * 180) / Pi;

    // Normalize to 0-360

    if (heading < 0)

    {

    heading = 360 + heading;

    }

    for (int c=0; c <333; c++) {

    disp.write(heading);

    }

    delay(15);

    }

    void changeMode() {

    ++indexMode %= 3;

    }

  • PCB beginnings

    bret.wiebe07/29/2015 at 20:28 0 comments

    Just rediscovered Upverter, have started learning the ropes and creating my schematic. The goal is to layout a pcb for the "permanent" version of this thing. I have some protoboards that I could use, but as a large motivation behind this endeavour is to learn new stuff I would prefer to get some experience with producing a pcb layout.

  • Some (more) progress

    bret.wiebe06/26/2015 at 19:32 0 comments

    Here's a schematic of the current setup. Had to do a little connection shuffling to free up digital pin 2 for the external interrupt, using the tact switch to change modes (poem, clock, compass). Next step is to gather the useful parts of my various test sketches into a functioning unit and tweak the poetry portion.

  • Some progress...

    bret.wiebe06/04/2015 at 16:27 0 comments

    The two modules arrived and I assembled the DS1307 RTC kit. The basic code for generating the "poems" is working (still on the Pro Mini). I attempted to compile it for the Teensy-LC but got an error related to the library I'm using for the seven segment display and a warning related to using an array of strings. I'm debating whether to figure these issues out now before proceeding with the Teensy-LC or if I should continue with the Pro Mini and then adapt for the LC later. Any ideas of alternative ways to handle the seven segment display on the Teensy?

  • Parts acquisition

    bret.wiebe05/14/2015 at 16:23 0 comments

    Just ordered the RTC and magnetometer modules. Decided on the LSM303 triple-axis accelerometer and magnetometer from Adafruit as the feature/price factor seemed like the best value. Continuing to sketch ideas about how to use the seven segment display in various ways and reconfigured the circuit-thus-far on the breadboard to make room for the two modules.