Show Posts
|
|
Pages: [1] 2
|
|
2
|
Using Arduino / General Electronics / Struggling to understand the basics of a 7 segment display common anode
|
on: February 09, 2013, 10:55:22 pm
|
I have built something similar to this.  My LED works fine. The problem is I do not understand how the circuit works. The anode side, display pins 3 and 8, receive power. Lets say for now I have pin 2 of the display going to pin 2 on the arduino board. Now in my mind the pin 2 on the arduino board should complete/ground the circuit. However the program sketch uses pinmode(2, OUTPUT) and I use digitalWrite(2, HIGH) to turn on that specific led. How does the cathode side of this CA 7-seg display work?
|
|
|
|
|
5
|
Using Arduino / LEDs and Multiplexing / Re: Electronics 101, Ohm's law, Arduino and blue leds! Beginner here...
|
on: February 02, 2013, 04:09:14 pm
|
Sure. I am just using the basic blink example program. /* Blink Turns on an LED on for one second, then off for one second, repeatedly. This example code is in the public domain. */ // Pin 13 has an LED connected on most Arduino boards. // give it a name: int led = 13;
// the setup routine runs once when you press reset: void setup() { // initialize the digital pin as an output. pinMode(led, OUTPUT); }
// the loop routine runs over and over again forever: void loop() { digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }
I checked the led polarity. Looks correct. I can send a pic later if needed.
|
|
|
|
|
7
|
Using Arduino / LEDs and Multiplexing / Electronics 101, Ohm's law, Arduino and blue leds! Beginner here...
|
on: February 02, 2013, 03:37:30 pm
|
Hi everyone, Apologizes for the very basic question. I am struggling to understand what kind of resistor to use for a specific LED. I have 10 blue LEDS and an arduino uno. The packaging on the led states, "3.0-3.3v @ 20mA". Possibly I am not understanding how to calculate this. I have been studying from this site. I tried to search the forums but I don't know if anyone has dared to ask a question as basic as this...  I want to blink this blue LED on a digital pin. Is this as simple as (5.0 - 3.3) / 0.02 = r ?
|
|
|
|
|
9
|
Using Arduino / Project Guidance / Re: Cannot blink pins 7 through 5 (NEWBIE)
|
on: January 27, 2013, 09:35:09 pm
|
Alright well I have a working clock. In my excitement to get it all working I may have mangled my code a bit. I had to add a crude setup process so you could set the right time. Still it is wonderful that I got it up and running. Now I can refine it and improve it. Since this is the first real thing I've made with Arduino it has spiked a load of questions regarding electronics. Some of resistors I used were guess work. I'll probably post some followup questions in the electronics forum. Below is what I have so far in my code. //#define NUM_ITEMS(arg) ((unsigned int) (sizeof (arg) / sizeof (arg [0])))
int const MINUTES[] = {13, 12, 11, 10, 9, 8}; int const HOURS[] = {7, 6, 5, 4}; int hours = 1; int minute = 0; int setup_time = 10000;
void setup() { for(int led = 4; led < 14; led++){ pinMode(led, OUTPUT); } //Serial.begin(9600); pinMode(3, INPUT); }
//int array_size(int const a[]) { // return (sizeof(a)/sizeof(int)); //}
void blink_binary_number(int number, int const pin_array[], int a_size){ for(int led = 0; led < a_size; led++){ if (bitRead(number, led) == 1){ digitalWrite(pin_array[led], HIGH); } else { digitalWrite(pin_array[led], LOW); } } }
void loop() { while (setup_time > 0) { if (digitalRead(3) == HIGH) { // Serial.print("Minute: "); // Serial.println(minute); // Serial.print("Hour: "); // Serial.println(hours); // Serial.println("------"); blink_binary_number(hours, HOURS, 4); blink_binary_number(minute, MINUTES, 6);
//Incriment time minute++; if (minute == 60) { minute = 0; hours++; } if (hours > 12) { hours = 1; } delay(150); setup_time = 10000; } else { delay(10); setup_time = setup_time - 10; } } // Serial.print("Minute: "); // Serial.println(minute); // Serial.print("Hour: "); // Serial.println(hours); // Serial.println("------"); blink_binary_number(hours, HOURS, 4); blink_binary_number(minute, MINUTES, 6);
//Incriment time minute++; if (minute == 60) { minute = 0; hours++; } if (hours > 12) { hours = 1; } delay(60000); }
 Uploading a video now.
|
|
|
|
|
11
|
Using Arduino / Project Guidance / Re: Cannot blink pins 7 through 5 (NEWBIE)
|
on: January 27, 2013, 02:37:56 pm
|
I've made some wonderful progress. I have all my pins blinking and my binary counting for the hour leds and minute leds are working great. I've cleaned up my blink_to_binary function a bit so that it only needs to be called once per array of pins. #define NUM_ITEMS(arg) ((unsigned int) (sizeof (arg) / sizeof (arg [0])))
int const MINUTES[] = {13, 12, 11, 10, 9, 8}; int const HOURS[] = {7, 6, 5, 4}; int const delayms = 500; int hours = 1;
void setup() { for(int led = 4; led < 14; led++){ pinMode(led, OUTPUT); } Serial.begin(9600); }
int array_size(int const a[]) { return (sizeof(a)/sizeof(int)); }
void blink_binary_number(int number, int const pin_array[], int a_size){ for(int led = 0; led < a_size; led++){ if (bitRead(number, led) == 1){ digitalWrite(pin_array[led], HIGH); } else { digitalWrite(pin_array[led], LOW); } } }
void loop() { for(int x = 0; x < 60; x++){ Serial.print("Minute: "); Serial.println(x); Serial.print("Hour: "); Serial.println(hours); Serial.println("------"); blink_binary_number(hours, HOURS, 4); blink_binary_number(x, MINUTES, 6); if (x == 59) { hours++; } if (hours > 12) { hours = 0; } delay(delayms); } } I did run into a snag with catching array size. I wanted my bit_to_binary function to be able to handle any array size. I also don't want it trying to access the next element in an array if it doesn't exist so I only want to count up to the array size. I made two array_size functions to accomplish this. NUM_ITEMS and array_size. If I run these inside of my blink_binary_number the array size is always one. I want to do something like this void blink_binary_number(int number, int const pin_array[]){ a_size = array_size(pin_array);
for(int led = 0; led < a_size; led++){ if (bitRead(number, led) == 1){ digitalWrite(pin_array[led], HIGH); } else { digitalWrite(pin_array[led], LOW); } } } void loop() { blink_binary_number(number, HOURS_ARRAY); }
However every time I run this method inside of the blink_binary_number HOURS_ARRAY always returns 1. If I run it from within void loop it correctly returns a length of 4. For now I just pass the array size into the function but it would be nice if the function could just handle this for me. I know this is probably due to a lack of understanding in what is going with hour the array is referenced. Can someone help me understand this? I'll send pictures and perhaps a video of what I have so far in a bit.
|
|
|
|
|
14
|
Using Arduino / Project Guidance / Re: Cannot blink pins 7 through 5 (NEWBIE)
|
on: January 26, 2013, 01:10:50 pm
|
You are assuming that your sketch does what you want. I'm saying don't make that assumption;
Well presently I am not sure what is going on. Hence the post here. I suspected something wrong with my sketch. write a sketch that just turns that output HIGH in the simplest possible way.
Right. Which is why I tried using the blink example sketch. You may have missed this but the second post mentions that I tried this. You don't need github or anything else to write that.
I don't follow. Github isn't used for writing sketches. Eliminate all the superfluous hardware and just test one specific output with your LED and current limiting resistor. Don't allow any other complexity at all into your test system.
This is a good point. I plan on trying this and Hazards notes tonight when I get a chance. Thanks for the feedback Peter.
|
|
|
|
|
15
|
Using Arduino / Project Guidance / Re: Cannot blink pins 7 through 5 (NEWBIE)
|
on: January 26, 2013, 01:05:16 pm
|
Pins 5 & 6 are PWM so they will work with analogWrite. 7 is digital. I found out that I burnt out my Nano, and my pins would only go high when I did analogWrite(pin, 255) and not digitalWrite(pin,HIGH).
Ok I will definitely try this tonight. I am beginning to wonder if I did this. Fortunately I do have another uno I can test on as well. Thanks HazardsMind I'll keep you posted.
|
|
|
|
|