Arduino Antics

A blog about Arduino, and my antics to master it!

RSS
  • Home
  • Posts RSS
  • Comments RSS
  • For Sale/Wanted

Progress

Wednesday, April 21, 2010 by SJ | 0 comments
After some work, I've managed to get this darned thing to fade an LED in and out!

An arduino writes values from 0-255 on Potentiometer 1 (I'm having some trouble with Pot 0, see below), and the chip then writes that value to the Pot, creating a voltage divider that fades in/out an LED! It's progress, and it's a positive sign for creating a library!

I am, however, having problems with Pot 0. For some reason, When I try sending the command bit addressing Pot 0 (B00010001), it simply doesn't work. That pot appears to be stuck on 127 (5k resistance). But, when I send the command for Pot 1 (B00010010), that pot functions fine, exactly as I expect.

Also oddly, when I send the command to write both pots (B00010011), neither work! This is very confusing.. Here's the code I'm currently using if anyone wants to give some advice:



#define sLatch 2
#define sClock 3
#define sData 4
#define commandData B00010001 // command = write to pot 0

byte data;

void setup()
{
pinMode(sLatch, OUTPUT);
pinMode(sClock, OUTPUT);
pinMode(sData, OUTPUT);
}

void loop()
{
for (int i = 0; i<256; i++) { digitalWrite(sLatch, LOW); shiftOut(sData, sClock, MSBFIRST, commandData); shiftOut(sData, sClock, MSBFIRST, i); digitalWrite(sLatch, HIGH); delay(5); } for (int i = 255; i>-1; i--) {
digitalWrite(sLatch, LOW);
shiftOut(sData, sClock, MSBFIRST, commandData);
shiftOut(sData, sClock, MSBFIRST, i);
digitalWrite(sLatch, HIGH);
delay(5);
}
}

Thanks for looking, I'll check back when I get something new happening!

-Stephen


No comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Donate

Money is tight for hobbies like this. If you want to, please donate a little to help me out :). Every little bit helps!

Followers

Blog Archive

  • ►  2011 (1)
    • ►  May (1)
  • ▼  2010 (7)
    • ►  June (1)
    • ►  May (1)
    • ▼  April (5)
      • More progress
      • Progress
      • A box on the doorstep!
      • Planning my first library!
      • Welcome to my Blog!
Copyright © 2010 Arduino Antics Wordpress Theme Blogger Template Credits For