Show Posts
Pages: 1 ... 11 12 [13] 14
181  Using Arduino / LEDs and Multiplexing / Re: A simple single digit seven segment display on: October 12, 2012, 06:03:37 am
That will make it display a two on top of a seven.

You first have to define which pins you connect abcdefg segments to in your sketch. Then if you type zero(); then the seven segment display will display zero, one(); will display one, etc. zerooff(); will turn zero off. clearall(); will turn everything off. This is an example:
Quote
#include"sevenseg.h"
int test;
#define a 13
#define b 12
#define c 11
#define d 10
#define e 9
#define f 8
#define g 7
#define dp 6
void setup(){
  pinMode(a, OUTPUT);
  pinMode(b, OUTPUT);
  pinMode(c, OUTPUT);
  pinMode(d, OUTPUT);
  pinMode(e, OUTPUT);
  pinMode(f, OUTPUT);
  pinMode(g, OUTPUT);
  pinMode(dp, OUTPUT);
}
void loop(){
  zero();
  delay(1000);
  zerooff();
  one();
  delay(1000);
  oneoff();
  two();
  delay(1000);
  twooff();
  three();
  delay(1000);
  threeoff();
  four();
  delay(1000);
  fouroff();
  five();
  delay(1000);
  fiveoff();
  six();
  delay(1000);
  sixoff();
  seven();
  delay(1000);
  sevenoff();
  eight();
  delay(1000);
  eightoff();
  nine();
  nineoff();
}

[/quote]
182  Using Arduino / LEDs and Multiplexing / A simple single digit seven segment display on: October 12, 2012, 05:06:55 am
I wrote a simple library for a common cathode seven segment display, you can add it in a new tab.
Please feel free to use it or post comments!
Quote
#include<Arduino.h>
#define a 13
#define b 12
#define c 11
#define d 10
#define e 9
#define f 8
#define g 7
#define dp 6 
void zero(){
  digitalWrite(a, HIGH);
  digitalWrite(d, HIGH);
  digitalWrite(f, HIGH);
  digitalWrite(e, HIGH);
  digitalWrite(b, HIGH);
  digitalWrite(c, HIGH);
}
void zerooff(){
  digitalWrite(a, LOW);
  digitalWrite(d, LOW);
  digitalWrite(f, LOW);
  digitalWrite(e, LOW);
  digitalWrite(b, LOW);
  digitalWrite(c, LOW);
}
void one(){
  digitalWrite(b, HIGH);
  digitalWrite(c, HIGH);
}
void oneoff(){
  digitalWrite(b, LOW);
  digitalWrite(c, LOW);
}
void two(){
  digitalWrite(a, HIGH);
  digitalWrite(b, HIGH);
  digitalWrite(g, HIGH);
  digitalWrite(e, HIGH);
  digitalWrite(d, HIGH);
}
void twooff(){
  digitalWrite(a, LOW);
  digitalWrite(b, LOW);
  digitalWrite(g, LOW);
  digitalWrite(e, LOW);
  digitalWrite(d, LOW);
}
void three(){
  digitalWrite(a, HIGH);
  digitalWrite(b, HIGH);
  digitalWrite(g, HIGH);
  digitalWrite(c, HIGH);
  digitalWrite(d, HIGH);
}
void threeoff(){
  digitalWrite(a, LOW);
  digitalWrite(b, LOW);
  digitalWrite(g, LOW);
  digitalWrite(c, LOW);
  digitalWrite(d, LOW);
}
void four(){
  digitalWrite(f, HIGH);
  digitalWrite(g, HIGH);
  digitalWrite(b, HIGH);
  digitalWrite(c, HIGH);
}
void fouroff(){
  digitalWrite(f, LOW);
  digitalWrite(g, LOW);
  digitalWrite(b, LOW);
  digitalWrite(c, LOW);
}
void five(){
  digitalWrite(a, HIGH);
  digitalWrite(f, HIGH);
  digitalWrite(g, HIGH);
  digitalWrite(c, HIGH);
  digitalWrite(d, HIGH);
}
void fiveoff(){
  digitalWrite(a, LOW);
  digitalWrite(f, LOW);
  digitalWrite(g, LOW);
  digitalWrite(c, LOW);
  digitalWrite(d, LOW);
}
void six(){
  digitalWrite(a, HIGH);
  digitalWrite(f, HIGH);
  digitalWrite(e, HIGH);
  digitalWrite(g, HIGH);
  digitalWrite(c, HIGH);
  digitalWrite(d, HIGH);
}
void sixoff(){
  digitalWrite(a, LOW);
  digitalWrite(f, LOW);
  digitalWrite(e, LOW);
  digitalWrite(g, LOW);
  digitalWrite(c, LOW);
  digitalWrite(d, LOW);
}
void seven(){
  digitalWrite(a, HIGH);
  digitalWrite(b, HIGH);
  digitalWrite(c, HIGH);
}
void sevenoff(){
  digitalWrite(a, LOW);
  digitalWrite(b, LOW);
  digitalWrite(c, LOW);
}
void eight(){
  digitalWrite(a, HIGH);
  digitalWrite(b, HIGH);
  digitalWrite(c, HIGH);
  digitalWrite(d, HIGH);
  digitalWrite(e, HIGH);
  digitalWrite(f, HIGH);
  digitalWrite(g, HIGH);
}
void eightoff(){
  digitalWrite(a, LOW);
  digitalWrite(b, LOW);
  digitalWrite(c, LOW);
  digitalWrite(d, LOW);
  digitalWrite(e, LOW);
  digitalWrite(f, LOW);
  digitalWrite(g, LOW);
}
void nine(){
  digitalWrite(a, HIGH);
  digitalWrite(f, HIGH);
  digitalWrite(g, HIGH);
  digitalWrite(b, HIGH);
  digitalWrite(c, HIGH);
}
void nineoff(){
  digitalWrite(a, LOW);
  digitalWrite(f, LOW);
  digitalWrite(g, LOW);
  digitalWrite(b, LOW);
  digitalWrite(c, LOW);
}
void clearall(){
  oneoff();
  twooff();
  threeoff();
  fouroff();
  fiveoff();
  sixoff();
  sevenoff();
  eightoff();
  nineoff();
  zerooff();
}

183  Using Arduino / Programming Questions / Re: Error compiling again! on: October 05, 2012, 10:15:03 pm
I have a Mega 2560. How do I modify the timer?
P.S. I modified the code so it doesn't use "pitches.h".
Quote
Quote
#include <IRremote.h>
int RECV_PIN = 8;
int ledPin =  7;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  pinMode(ledPin, OUTPUT);
}
 
void loop() {
 
  if (irrecv.decode(&results)) {
    Serial.println(results.value, DEC);
  }
    if(results.value == 150996993){
      tone(6, 262, 4);
  }
    if(results.value == 151029889){
      tone(6, 294, 4);
    }
    if(results.value == 151013441){
      tone(6, 330, 4);
    }
    irrecv.resume(); // Receive the next value
  }

184  Using Arduino / Programming Questions / Re: Error compiling again! on: October 05, 2012, 06:47:32 pm
So what can I do about it?
185  Using Arduino / Programming Questions / Re: Error compiling again! on: October 04, 2012, 01:01:51 am
Oh ok this is what it is:
Quote
core.a(Tone.cpp.o): In function `__vector_13':
C:\Users\Habib\Downloads\arduino-1.0.1-windows (2)\arduino-1.0.1\hardware\arduino\cores\arduino/Tone.cpp:523: multiple definition of `__vector_13'
arduinoirremote\IRremote.cpp.o:D:\Tech\Arduino\libraries\arduinoirremote/IRremote.cpp:311: first defined here
c:/users/habib/downloads/arduino-1.0.1-windows (2)/arduino-1.0.1/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions
186  Using Arduino / Programming Questions / Re: Error compiling again! on: October 04, 2012, 12:30:18 am
The error message is "error compiling", and I do have "pitches.h" on in the other tab.
187  Using Arduino / Programming Questions / Error compiling again! on: October 04, 2012, 12:16:29 am
I asked this question before, and I am ashamed to ask this question again, but I have encountered the"Error Compiling" message when I try to compile my program. When I asked this question last time, I was asked to add
Quote
// WCharacter.h prototypes
inline boolean isAlphaNumeric(int c) __attribute__((always_inline));
to the program, or to put an other deceleration in the front. But this time these two methods don't work. Can anyone help me? A million thanks.
P.S. This is the code I am trying to compile:
Quote
#include "pitches.h"
#include <IRremote.h>
int RECV_PIN = 8;
int ledPin =  7;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  pinMode(ledPin, OUTPUT);
}
 
void loop() {
 
  if (irrecv.decode(&results)) {
    Serial.println(results.value, DEC);
  }
    if(results.value == 150996993){
      tone(6, NOTE_C4, 4);
  }
    if(results.value == 151029889){
      tone(6, NOTE_D4, 4);
    }
    if(results.value == 151013441){
      tone(6, NOTE_E4, 4);
    }
    irrecv.resume(); // Receive the next value
  }

188  Using Arduino / Programming Questions / Re: Error compiling on: September 29, 2012, 07:20:12 am
Thank you everybody for the quick reply and your methods your methods all work!
189  Using Arduino / Programming Questions / Error compiling on: September 29, 2012, 07:02:19 am
I wrote a code for a one digit seven segment display(that took me a while) and when I try to upload to board it says "error compiling. Its driving me mad because there aren't any mistakes in the actual code and I have been trying to get a seven segment display to work for a while. What should I do? Please someone help me!
Thanks
P.S. this is the code:
Quote
#define a 13
#define b 12
#define c 11
#define d 10
#define e 9
#define f 8
#define g 7
#define dp 6 
void setup(){
  pinMode(a, OUTPUT);
  pinMode(b, OUTPUT);
  pinMode(c, OUTPUT);
  pinMode(d, OUTPUT);
  pinMode(e, OUTPUT);
  pinMode(f, OUTPUT);
  pinMode(g, OUTPUT);
  pinMode(dp, OUTPUT);
}
void loop(){
  digitalWrite(b, HIGH);
  digitalWrite(c, HIGH);
  delay(1000);
  digitalWrite(b, LOW);
  digitalWrite(c, LOW);
  digitalWrite(a, HIGH);
  digitalWrite(b, HIGH);
  digitalWrite(g, HIGH);
  digitalWrite(e, HIGH);
  digitalWrite(d, HIGH);
  delay(1000);
  digitalWrite(a, LOW);
  digitalWrite(b, LOW);
  digitalWrite(g, LOW);
  digitalWrite(e, LOW);
  digitalWrite(d, LOW);
  delay(1000);
  digitalWrite(a, HIGH);
  digitalWrite(b, HIGH);
  digitalWrite(g, HIGH);
  digitalWrite(c, HIGH);
  digitalWrite(d, HIGH);
  delay(1000);
  digitalWrite(a, LOW);
  digitalWrite(b, LOW);
  digitalWrite(g, LOW);
  digitalWrite(c, LOW);
  digitalWrite(d, LOW);
  digitalWrite(f, HIGH);
  digitalWrite(g, HIGH);
  digitalWrite(b, HIGH);
  digitalWrite(c, HIGH);
  delay(1000);
  digitalWrite(f, LOW);
  digitalWrite(g, LOW);
  digitalWrite(b, LOW);
  digitalWrite(c, LOW);
  digitalWrite(a, HIGH);
  digitalWrite(f, HIGH);
  digitalWrite(g, HIGH);
  digitalWrite(c, HIGH);
  digitalWrite(d, HIGH);
  delay(1000);
  digitalWrite(a, LOW);
  digitalWrite(f, LOW);
  digitalWrite(g, LOW);
  digitalWrite(c, LOW);
  digitalWrite(d, LOW);
  digitalWrite(a, HIGH);
  digitalWrite(f, HIGH);
  digitalWrite(e, HIGH);
  digitalWrite(g, HIGH);
  digitalWrite(c, HIGH);
  digitalWrite(d, HIGH);
  delay(1000);
  digitalWrite(a, LOW);
  digitalWrite(f, LOW);
  digitalWrite(e, LOW);
  digitalWrite(g, LOW);
  digitalWrite(c, LOW);
  digitalWrite(d, LOW);
  digitalWrite(a, HIGH);
  digitalWrite(b, HIGH);
  digitalWrite(c, HIGH);
  delay(1000);
  digitalWrite(a, LOW);
  digitalWrite(b, LOW);
  digitalWrite(c, LOW);
  digitalWrite(a, HIGH);
  digitalWrite(b, HIGH);
  digitalWrite(c, HIGH);
  digitalWrite(d, HIGH);
  digitalWrite(e, HIGH);
  digitalWrite(f, HIGH);
  digitalWrite(g, HIGH);
  delay(1000);
  digitalWrite(a, LOW);
  digitalWrite(b, LOW);
  digitalWrite(c, LOW);
  digitalWrite(d, LOW);
  digitalWrite(e, LOW);
  digitalWrite(f, LOW);
  digitalWrite(g, LOW);
  digitalWrite(a, HIGH);
  digitalWrite(f, HIGH);
  digitalWrite(g, HIGH);
  digitalWrite(b, HIGH);
  digitalWrite(c, HIGH);
  delay(1000);
  digitalWrite(a, LOW);
  digitalWrite(f, LOW);
  digitalWrite(g, LOW);
  digitalWrite(b, LOW);
  digitalWrite(c, LOW);
  digitalWrite(a, HIGH);
  digitalWrite(d, HIGH);
  digitalWrite(f, HIGH);
  digitalWrite(e, HIGH);
  digitalWrite(b, HIGH);
  digitalWrite(c, HIGH);
  delay(1000);
  digitalWrite(a, LOW);
  digitalWrite(d, LOW);
  digitalWrite(f, LOW);
  digitalWrite(e, LOW);
  digitalWrite(b, LOW);
  digitalWrite(c, LOW);
}

190  Using Arduino / Displays / Re: LCD Problems on: August 13, 2012, 10:22:12 pm
Haha! I live in Beijing, China!
191  Using Arduino / Displays / Re: LCD Problems on: August 13, 2012, 09:15:04 pm
Yes!! You are right! There was a soldering problem with DB7 and DB6. Thank you so much! And I certainly owe you a new pair of glasses! How did you figure that out?
 smiley smiley smiley
192  Using Arduino / Displays / Re: LCD Problems on: August 13, 2012, 09:36:43 am
I wrote "hello, world!"
193  Using Arduino / Displays / LCD Problems on: August 13, 2012, 03:27:32 am
I have an LCD screen and I wired it up to my Arduino and loaded the "Hello World" sketch to my Arduino and this is gibberish appeared on the screen. The picture is on my blog: http://habibifier.blog.com/2012/08/13/lcd-problems/
What is the problem and how do I fix it?
Thanks so much!
194  Using Arduino / General Electronics / Re: Reverse polarity on: August 06, 2012, 11:44:56 pm
Thank you so much for your help!
195  Using Arduino / General Electronics / Re: Reverse polarity on: August 06, 2012, 09:01:50 pm
Do I have to use a shield? Is there a bare-bones way to do it?
Pages: 1 ... 11 12 [13] 14