Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Development / Re: e3 RGB-lit LCD switches / 60000 Baud clock on: January 06, 2010, 08:09:17 am
I think my soldering needs to be redone and I might end up converting this code to do the jobby I need (which is have the screenkey and a few other components more or less slaved to another arduino. This code looks complicated but good if I can make it dance too

The hex numbering thing still confuses me how it works with these pins. Id expect it to go like

0, 1, 2, 3, 4, 5, 6, 7, 8, 9 in dec is
0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8 in hex
(well thats how i remember learning it, its been a while so i checked in case i am drunk or something)

But I found someones code that if I understand it the pin numbering goes (starting at 1) like:

0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 (making 0x80 = 7)

I'm not getting to use the coding part of my brain at work so maybe its taking a while to warm up after a long day. Perhaps on the weekend it will click for me.
2  Forum 2005-2010 (read only) / Development / Re: e3 RGB-lit LCD switches / 60000 Baud clock on: January 05, 2010, 03:13:35 am
Aha! Thankyou hugely. Apart from the solder I just broke playing with it changing it over to PIND & 0x80 changed it to PD7 which is digital pin 7 worked fine.

I saw the line but the 0x80 didnt make sense to me as I thought well if its hex that should be 128. But seeing how it means 7 then im guessing it was 0x8... which is confusing, what type of numbering is that exactly?
3  Forum 2005-2010 (read only) / Development / Re: e3 RGB-lit LCD switches / 60000 Baud clock on: January 04, 2010, 06:20:27 am
Ok so I have a screenkey, found the sparkfun code, modified it to run on the arduino. Heres the thing, I might of modified to make it work doesnt mean I understand a single part of it.

Im fumbling through here which Im ok with, I can figure most things out given enough time - but... not being able to read this AVR code doesnt help at all.

All I want to know is - where the hell is the part that talks about the button and its pin assignment? The original code say PB7 which according to the ardiuno/pin assignment is a crystal. Still dont get where that part is.

If someone could point out the bit of code relating to that pin assignment then I could figure out how it uses the PB1/dig pin9 and PB0/dig pin8. Or if there is a dummies dummy guide to AVR atleast Id take that

#include <avr/io.h>
#include <avr/interrupt.h>
#include "start.h"
#include "stop.h"

volatile uint8_t phase;
volatile uint16_t bits;
volatile uint8_t cnt;
volatile uint16_t fcnt=0;

// This file is designed to be used on an atmega 640, running @ 16mhz,
// but should be portable to other processors
// Pin assignments are:
//       PB7 - Button input [button drives pin low] (somewhere?)
//       PB1 - Data (digital pin 9)
//       PB0 - Clock (digital pin 8)

  TCNT1 = 65536-80;

  phase = ~phase;

   PORTB = (PORTB & 0XFE) | (phase?1:0 );
  if (phase)
        if (!cnt)
            PORTB |= 0x2;

      PORTB = (PORTB & 0xFD) | ((bits & 0x1) ? 2:0);
        cnt --;
      bits = bits >> 1;

/* Prepares a word to be sent to the lcd */
/* Parity is 1 for odd parity, 0 for even */
void screenkey_write(uint8_t data, uint8_t parity)
      /* Block while theres still a word being sent */
      while (cnt);

      /* Calculate parity */
      uint8_t pb = data ^ (data >> 1) ^ (data >> 2) ^ (data >> 3) ^
            (data >> 4) ^ (data >> 5) ^ (data >> 6) ^ (data >> 7)
            ^ parity;

      /* Setup the bits to send */
      bits = 0x0C00 | (data << 1) | ((pb & 0x1) << 9);

      /* queue it up */
      cnt = 12;

/* Start / Stop characters */
void screenkey_start()
      screenkey_write(0x00, 0);

void screenkey_stop()
      screenkey_write(0xAA, 0);

// Write a 1 byte register
void screenkey_reg_1(uint8_t reg, uint8_t val)


// Write a 2 byte register
void screenkey_reg_2(uint8_t reg, uint8_t val1, uint8_t val2)

// Write a 108 byte image to the screen
// Data is a pointer to 108 bytes of image data to display
void screenkey_write_img(uint8_t * data)
      uint8_t i;

      for (i=0; i<108; i++)
            screenkey_write(data[i], 1);



// Bright and dark constants for each color
#define BR_GREEN 0x44
#define BR_RED       0x22
#define BR_BLUE  0x11
#define DK_GREEN 0x04
#define DK_RED   0x02
#define DX_BLUE  0x01

// Call with constants above, use | to make composite colors
// aka Blueish purple: BR_BLUE | DK_RED
void screenkey_set_color(uint8_t color)
      screenkey_reg_1(0xED, color);

// Application specific
void show_start()

void show_stop()

void setup()
      enum {
      } state;

      uint8_t btn_db;
      uint8_t br_dim;

      cnt = 0;
      DDRB = 0x3;
      PORTB = 0x83;

      TCCR1A = 0x00;

      TCCR1B = 0x01;
      TCCR1C = 0x0;


      // Setup the control registers
      screenkey_reg_1(0xEE, 0x00);
      screenkey_reg_2(0xEF, 0x07, 0x00);
      state = stopped;

      while (1)
            /* Button Debounce */
            uint8_t btn = PINB & 0x80;
            if (!btn)
                  if (btn_db < 0x4)
                        btn_db ++;

                  if (btn_db == 0x4)
                        btn_db = 0xFF;
                        /* Button State */
                        if (state == running)
                              state = stopped;
                        else if (state == stopped)
                              fcnt = 0;
                              state = running;

                  btn_db = 0;

            /* Blink animation for stop display */
            if (state==running)
                  if (fcnt & 0x8000)
                        if (!br_dim)
                              br_dim = 1;
                  if (! (fcnt & 0x8000))
                        if (br_dim)
                              br_dim = 0;

void loop()

Also yes, I feel very dumb for not being able to figure this out myself yet.
4  Forum 2005-2010 (read only) / Interfacing / Re: Super Capacitors as a Power Supply? on: January 01, 2010, 07:18:04 am
Yee of little faith...

I was kinda thinking just the supercap to a 5v booster/regulator (maybe the pololu one - or maybe USB to recharge....

Im building a sort of all purpose handheld tool. I could live with recharging as long as I get a little use, 5 minutes wouldnt be acceptable but say 2 hours or even 4 would be. I think I can fit 1 or 2 55F supercaps with the space im trying to keep to (smaller the better as youd expect but i can make some allowances).
5  Forum 2005-2010 (read only) / Interfacing / Re: Super Capacitors as a Power Supply? on: December 31, 2009, 08:50:23 pm
What about this?

I understand these wouldnt work too long such as this...

But that seems to be under a bit of load, would an ardiuno and a few other not so heavy use components (umm like say switches, leds, maybe sd card reader?) last a bit longer? If you had say an hour or two of use for example for a 60 second recharge that would be pretty cool depending on the project you made.
6  Forum 2005-2010 (read only) / Interfacing / Re: Super Capacitors as a Power Supply? on: December 31, 2009, 08:50:00 pm
Ive been looking at Supercaps too, I found one thats 55F but I think I need to refresh myself on the electronics side as Im having to look stuff up a lot. But there are supercap flashlights you can get and Ive seen a few mods to use them when you look. evilmadscientist had a comp and I think there was one guy who had a single led going for months.
Pages: [1]