NEWBIE:  Switch Ground between 3 pins

Hello im new to all this

some gave me an Freeduino digital to play with
how do i set three of the digital pins to ground, and how do i switch between three grounds

thanks jason

im playing with the cube that i found on this forum
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1203613060

These are the pins im using so far
int ledPin0 = 0; // + LED connected to digital pins 0 → 8
int ledPin1 = 1;
int ledPin2 = 2;
int ledPin3 = 3;
int ledPin4 = 4;
int ledPin5 = 5;
int ledPin6 = 6;
int ledPin7 = 7;
int ledPin8 = 8;

please help thanks jason

hello folks, maybe im asking the wrong questions.

in the code from the link you can download the files.
the code reads…

/*
The hardware for this project is as follows:
pin 1 connects to serial port programming circuitry
pin 2 PD0 - ground for top plane of 3x3 LEDs
pin 3 PD1 - ground for middle plane of 3x3 LEDs
pin 6 PD2 - ground for bottom plane of 3x3 LEDs
pin 7 PD3 - +V for lower-left LED of each plane
pin 10 ground
pin 12 PB0 - +V for upper-right LED of each plane
pin 13 PB1 - +V for upper-middle LED of each plane
pin 14 PB2 - +V for upper-right LED of each plane
pin 15 PB3 - +V for middle-right LED of each plane
pin 16 PB4 - +V for midle-middle LED of each plane
pin 17 PB5 - +V for middle-right LED of each plane – also connects to serial port programming circuitry
pin 18 PB6 - +V for lower-right LED of each plane – also connects to serial port programming circuitry
pin 19 PB7 - +V for lower-middle LED of each plane – also connects to serial port programming circuitry
pin 20 +3v
All other pins are unused

and it has some include files but i cant find them…
#include <avr/io.h> // this contains all the IO port definitions
#include <avr/interrupt.h> // definitions for interrupts
#include <avr/sleep.h> // definitions for power-down modes
#include <avr/pgmspace.h> // definitions or keeping constants in program memory

can you please send me in the right direction
many thanks jason

This is just a wild guess, as I’m a rank newbie, but I believe that setting an output pin LOW connects it to ground.

So, if you’re scanning through the planes of LEDs:

  • set all the ground outputs HIGH
  • set the individual +V pins high for whichever LEDs you want to light for a given plane
  • set the relevant ground pin LOW (all the selected LEDs light at this point)
  • repeat as desired (being sure to set all the ground pins HIGH first, so the next row doesn’t light up with the currently-selected LEDs), selecting a new ground pin to select a different plane

Thankyou ccarlson you are a star

this is how i got it to work

pinMode(ledPin11, HIGH); // Turn on ground
** digitalWrite(ledPin0, HIGH); // sets the LEDS on**
** delay(250); // waits for a second**
** digitalWrite(ledPin0, LOW); // sets the LED off**
** delay(20); // waits for a second**
** pinMode(ledPin11, LOW); // Turn off ground**
then just change between your ground pins

im still playing so i may find a better way to tidy up the code

thanks jason

Glad I could help.

I’ve been meaning to put together a LED cube, but kept putting it off. Perhaps I’ll do so now!

— Chris