Show Posts
|
|
Pages: [1] 2
|
|
2
|
Using Arduino / Programming Questions / Re: Button on Digital Pin of Shift Register
|
on: December 13, 2012, 10:36:29 am
|
Hm ok i thought everything should clear. But i try to describe it more in detail. I hooked up 4 shift registers like so: (example 2) http://arduino.cc/en/Tutorial/ShiftOut. I am using the shift registers to control 9 rgb less. For this i use the ShiftPWM Library. But this library is only for working with leds, so i cant use this library to get my button value (high or low). I hope its more understandable now ? Sorry but because i dont know how to program this i can't upload a little test sketch.
|
|
|
|
|
3
|
Using Arduino / Programming Questions / Button on Digital Pin of Shift Register
|
on: December 13, 2012, 10:24:42 am
|
I got 4 Shift Registers. On Q3 of register number 4 i'd like to hook up a button and whenever the button is pressed I'd like to recognize it. pinMode(Q3 of register 4, INPUT); if(Q3 of register 4 == HIGH) { }
So how can i accomplish that ? Any idea ? Thanks
|
|
|
|
|
6
|
Using Arduino / Audio / Piezo Buzzer - Win and Fail Sound
|
on: December 11, 2012, 03:47:09 pm
|
Hey, i am searching for two sound examples for my piezo buzzer. Currently i am using the piezo with the example from arduino int melody[] = { 262, 196,196, 220, 196,0, 247, 262};
// note durations: 4 = quarter note, 8 = eighth note, etc.: int noteDurations[] = { 4, 8, 8, 4,4,4,4,4 };
for (int thisNote = 0; thisNote < 8; thisNote++) { int noteDuration = 1000/noteDurations[thisNote]; tone(12, melody[thisNote],noteDuration); int pauseBetweenNotes = noteDuration * 1.30; delay(pauseBetweenNotes); noTone(12); }
But i am searching for a sound that underlines whether the user won or lost. But i can't find any examples for arduino/piezo sounds. So maybe you have some hints for me where i can find sounds like that for my arduino, or maybe you composed sounds like that by yourself  ?! Thanks
|
|
|
|
|
7
|
Using Arduino / Programming Questions / Re: Random number for RGB Led
|
on: December 11, 2012, 10:00:39 am
|
Yeah sure so my function would be something like void randomColor(int led) { int rand = random(0,3); if (rand == 0) { colorRed(led); } else if (rand == 1) { colorGreen(led); } else if (rand == 2) { colorBlue(led); } }
and then for (int i = 0;i<ledArray.length;i++) { randomColor(i); }
right ? I will try that out now.
|
|
|
|
|
8
|
Using Arduino / Programming Questions / Random number for RGB Led
|
on: December 11, 2012, 09:50:38 am
|
Hey, i have 9 RGB Led's. Each of this led should light up red, green or blue. Which color the led lights up should be randomly. Therefore i wrote this method (which works) but i hope that you can give me a better solution: int rand=random(0,2); if(rand == 0) { lightRed(led1); } else if (rand == 1) { lightGreen(led1); } else if (rand == 2) { lightBlue(led1); }
int rand2=random(0,2); if(rand2 == 0) { lightRed(led2); } else if (rand2 == 1) { lightGreen(led2); } else if (rand2 == 2) { lightBlue(led2); } .....
int rand9 = random(0,2); if(rand9 == 0) { lightRed(led9); } else if (rand9 == 1) { lightGreen(led9); } else if (rand9 == 2) { lightBlue(led9); }
....way to much code. There must be a more elegant solution. Thanks for your help.
|
|
|
|
|
10
|
Using Arduino / Programming Questions / Re: ShiftPWM and Tone Problem
|
on: December 08, 2012, 04:43:42 pm
|
Hm this is getting complicated... do you know a library which plays tone with timer1 ? ShiftPWM Library says it would use timer1 by default and just because i uncomment the define statement it would use timer 2. But if i uncomment the define statement again he tries to use timer3 and not timer1 by default... so maybe i should contact the developer of this library. // ShiftPWM uses timer1 by default. To use a different timer, before '#include <ShiftPWM.h>', add #define SHIFTPWM_USE_TIMER2 // for Arduino Uno and earlier (Atmega328)
|
|
|
|
|
11
|
Using Arduino / Programming Questions / ShiftPWM and Tone Problem
|
on: December 08, 2012, 04:02:25 pm
|
Hey, i got this ShiftPWM Library: https://github.com/elcojacobs/ShiftPWM/downloadsAt the beginning of the code i got this statement: #define SHIFTPWM_USE_TIMER2 If i just uncomment this i get this error message: "The avr you are using does not have a timer3" The problem is that i also want to play a tone on my piezo buzzer. Therefore i got this code: for (int thisNote = 0; thisNote < 8; thisNote++) { int noteDuration = 1000/noteDurations[thisNote]; tone(12, melody[thisNote],noteDuration); int pauseBetweenNotes = noteDuration * 1.30; delay(pauseBetweenNotes); noTone(12); } Which is working fine in a single project, but combined with the shiftpwm library and its define statment i get the following error message: core.a(Tone.cpp.o): In function `__vector_7': /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Tone.cpp:523: multiple definition of `__vector_7' ShiftPWM_RGB_Example.cpp.o:/Users/david/Documents/Arduino/libraries/ShiftPWM/ShiftPWM.h:190: first defined here
So i went to the Tone.cpp file and i saw that there is also an timer2 statement which (in my opinion) causes this error. I am new to this arduino stuff and i can make some minor bug fixes or something like that, but this error is too complicated for me at this time. Do you have an idea how i can solve the puzzle ? Btw if it helps you these are line 190 following from ShiftPW: #elif defined(SHIFTPWM_USE_TIMER2) //Install the Interrupt Service Routine (ISR) for Timer1 compare and match A. ISR(TIMER2_COMPA_vect) { ShiftPWM_handleInterrupt(); }
and line 523 following from Tone.cpp: ISR(TIMER2_COMPA_vect) {
if (timer2_toggle_count != 0) { // toggle the pin *timer2_pin_port ^= timer2_pin_mask;
if (timer2_toggle_count > 0) timer2_toggle_count--; } else { // need to call noTone() so that the tone_pins[] entry is reset, so the // timer gets initialized next time we call tone(). // XXX: this assumes timer 2 is always the first one used. noTone(tone_pins[0]); // disableTimer(2); // *timer2_pin_port &= ~(timer2_pin_mask); // keep pin low after stop } }
|
|
|
|
|
12
|
Using Arduino / LEDs and Multiplexing / Re: Light up RGB Led with 74hc595
|
on: December 06, 2012, 03:31:17 pm
|
shiftOut(dataPin, clockPin, MSBFIRST, 255); See that 255, that is saying make all the outputs a one. That is light up all the LEDs. If you only want to light up one then use a number that has only one bit with a one in it. Numbers like 1, 2, 4, 8, 16, 32, 64, or 128 How do you mean that ? How can i get the right number to my led or how can i assign a number to one of my led's ?
|
|
|
|
|
13
|
Using Arduino / LEDs and Multiplexing / Light up RGB Led with 74hc595
|
on: December 06, 2012, 03:08:14 pm
|
Hey, i got a shift register (74hc595) and i'd like to light up my rgb led. Everything is connected but i have problems with the code. Say my rgb led is connected to Q0,Q1 and Q2 of my shift register (Pin 15,1,2). How can i light up the rgb led (i want to switch between the color blue, green and red). I got this example which is working, but i don't know how to go on and how to achieve the thing mentioned above. //**************************************************************// // Name : shiftOutCode, Hello World // Author : Carlyn Maw,Tom Igoe, David A. Mellis // Date : 25 Oct, 2006 // Modified: 23 Mar 2010 // Version : 2.0 // Notes : Code for using a 74HC595 Shift Register // // : to count from 0 to 255 //****************************************************************
//Pin connected to ST_CP of 74HC595 int latchPin = 8; //Pin connected to SH_CP of 74HC595 int clockPin = 12; ////Pin connected to DS of 74HC595 int dataPin = 11;
void setup() { //set pins to output so you can control the shift register pinMode(latchPin, OUTPUT); pinMode(clockPin, OUTPUT); pinMode(dataPin, OUTPUT); }
void loop() { // count from 0 to 255 and display the number // on the LEDs
// take the latchPin low so // the LEDs don't change while you're sending in bits: digitalWrite(latchPin, LOW); // shift out the bits: shiftOut(dataPin, clockPin, MSBFIRST, 255);
//take the latch pin high so the LEDs will light up: digitalWrite(latchPin, HIGH); // pause before next value: delay(500); }
This lights up my rgb led which is has the color white-blue with this code. Please help me out and give me hints how to change the code so i can control whether my rgb led lights up green, red or blue. Thanks ! 
|
|
|
|
|
14
|
Using Arduino / Displays / Re: hook up LCD Shield
|
on: November 29, 2012, 01:38:21 pm
|
|
Ok danke ! Habe es nun hinbekommen... habe einfach das shield aufgesetzt und die pins per female/male jumper wire nutzen können. Tatsächlich sind die Button nur auf A0... hatte ich wohl überlesen. Also danke !
|
|
|
|
|
15
|
Using Arduino / Displays / hook up LCD Shield
|
on: November 29, 2012, 12:02:19 pm
|
Hey, i got a LCD Shield from DFRobot: http://www.robotshop.com/content/PDF/dfrobot-arduino-shields-manual.pdfNow i need to hook it up to my Arduino UNO, but i don't want the buttons (its a lcd + keypad) to waste my digital pins, because i dont need the keypad for my current project. So i thought i might not slide the shield above my arduino, but i connect it by myself via jumper wires, so i can only connect the pins i need or want. The lcd lights up when i connect Ground and 5V. But which pins from the lcd i need to connect to which pin of my arduino to change the text on the lcd ? i am not quite sure. I posted the datasheet above, also here you can see a picture of the lcd  Hopefully someone can guide me through this  Thanks
|
|
|
|
|