Show Posts
|
|
Pages: [1] 2 3 ... 6
|
|
3
|
Using Arduino / General Electronics / Re: Wind Up Arduino, dynamo generators..
|
on: February 18, 2013, 11:59:07 am
|
|
hi lefty, thanks a lot for your answer.
I don't know much about voltage regulators, could you maybe advise on which one should I try? Should it be 5volts or 9 volts? and how many Amps? mmmh really not sure.
The dynamo I would try to use is a really small one i savaged from a wind up radio. I could maybe try and use the circuit and the battery that came with it but I am not sure that could work.. on the battery it saus: Ni-MH Cell 2.4volts 300mAh
What do you think? Has anybody else tried this before?
Thanks!
|
|
|
|
|
6
|
Using Arduino / Project Guidance / Wifi/bluetooth sound help (DIY AirPlay?)
|
on: February 16, 2013, 07:27:03 am
|
|
Hey,
as part of a project i am developing I am trying to find the best way to fit wireless sound transmission in an object. What I am looking for is something similar to the many speakers that use the AirPlay protocol, so that people can use their apple devices to play music wirelessly.
Has anybody made their own diy airplay system? I am sure that 79£ for an airport express is definitively much more expensive than what the technology actually costs, right?
thanks
|
|
|
|
|
7
|
Using Arduino / Programming Questions / Re: Boolean and millis: doing it wrong?
|
on: December 18, 2012, 09:23:37 pm
|
Just introduced your bit... //Milano 0.1
int buttonPin = 4; int ledPin = 9; int fanPin = 10; boolean lastButton = LOW; boolean currentButton = LOW; int ledpwmLevel = 0; int lastLEDtime = 0; boolean fanOn = false;
void setup() { pinMode(buttonPin, INPUT); pinMode(ledPin, OUTPUT); pinMode(fanPin, OUTPUT); Serial.begin(9600); }
boolean debounce(boolean last) { boolean current = digitalRead(buttonPin); if (last != current) { delay(5); current = digitalRead(buttonPin); } return current; }
void loop() { currentButton = debounce(lastButton); if (lastButton == LOW && currentButton == HIGH) { fanOn = true; analogWrite(fanPin, 255); Serial.println("FANISON"); ledpwmLevel = ledpwmLevel + 85; Serial.println("BUTTON"); } if (ledpwmLevel > 255) { ledpwmLevel = 0; lastLEDtime = millis(); } analogWrite(ledPin, ledpwmLevel);
if (ledpwmLevel == 0 && fanOn && millis() - lastLEDtime > 5000)
//if (fanOn && ((millis() - lastLEDtime) > 5000))
{ fanOn = false; analogWrite(fanPin, 0); Serial.println("FANISOFF");
} lastButton = currentButton;
}
|
|
|
|
|
8
|
Using Arduino / Programming Questions / Re: Boolean and millis: doing it wrong?
|
on: December 18, 2012, 06:46:22 pm
|
|
Hi Peter,
Thanks for your suggestion, pretty good indeed! Now, the fan stays on all the time which is amazing. But I leave the light on one of the pwm steps for more then 5 seconds then the fan will not go on when the leds go of.. does that make any sense?
|
|
|
|
|
10
|
Using Arduino / Programming Questions / Boolean and millis: doing it wrong?
|
on: December 18, 2012, 05:43:54 pm
|
Hi there, I am still trying to figure out the best way to do this: I have some led (pin9) being dimmed by a button (pin4) and a cooling fan(pin 10) which needs to be on when the leds are on, and also to STAY on for some seconds when the leds are switched off. I am using boolean debounce and millis, but for some odd reason this only works the first time that I run it on the arduino, if I press the button again the fan doesn't switch on until the leds are off.. pretty confusing. Stupid mistake? //Milano 0.1
int buttonPin = 4; int ledPin = 9; int fanPin = 10; boolean lastButton = LOW; boolean currentButton = LOW; int ledpwmLevel = 0; int lastLEDtime = 0; boolean fanOn = false;
void setup() { pinMode(buttonPin, INPUT); pinMode(ledPin, OUTPUT); pinMode(fanPin, OUTPUT); Serial.begin(9600); }
boolean debounce(boolean last) { boolean current = digitalRead(buttonPin); if (last != current) { delay(5); current = digitalRead(buttonPin); } return current; }
void loop() { currentButton = debounce(lastButton); if (lastButton == LOW && currentButton == HIGH) { fanOn = true; analogWrite(fanPin, 255); ledpwmLevel = ledpwmLevel + 85; Serial.println("BUTTON"); } if (ledpwmLevel > 255) { ledpwmLevel = 0; lastLEDtime = millis(); } analogWrite(ledPin, ledpwmLevel);
if (fanOn && millis() - lastLEDtime > 5000)
{ fanOn = false; analogWrite(fanPin, 0); } lastButton = currentButton;
}
|
|
|
|
|
11
|
Using Arduino / Programming Questions / Re: PWM dimming + Fan output
|
on: December 17, 2012, 09:03:00 pm
|
|
hey thanks dude. i am gonna test it in a second, but just by clicking on the "play" button.. there seems to be some issue with the debounced thing you introduced. How does that work? the end bit seems great though! thanks a lot
|
|
|
|
|
12
|
Using Arduino / Programming Questions / PWM dimming + Fan output
|
on: December 17, 2012, 06:25:49 pm
|
|
Hi everyone,
I am making a sketch to control a lamp with leds and a cooling fan. Until now I have been using this sketch below, where booleans let me divide the pwm numbers into different parts.. When the button is pressed the light gets brighter, a bit like those ikea touch lamps. Now, I need another pin to connect a fan (i am using pin 10 at the moment) to the circuit. This fan should be on when the leds are on but should also stay on for some seconds when the leds will be switched off.. just to cool down the lamp. I have tried using millis, but didn't get really far. Maybe is the case to change my previous bit of code too? Maybe I should use different cases to dim the leds instead? I know it's very simple, but would be good to head someones help asap!
//
int buttonPin = 4; int ledPin = 9; int fanPin = 10; boolean lastButton = LOW; boolean currentButton = LOW; int ledpwmLevel = 0; int fanpwmLevel = 0;
void setup() { pinMode(buttonPin, INPUT); pinMode(ledPin, OUTPUT); pinMode(fanPin, OUTPUT); Serial.begin(9600); }
boolean debounce(boolean last) { boolean current = digitalRead(buttonPin); if (last != current) { delay(5); current = digitalRead(buttonPin); } return current; }
void loop() { currentButton = debounce(lastButton); if (lastButton == LOW && currentButton == HIGH) { ledpwmLevel = ledpwmLevel + 85; Serial.println("BUTTON"); } lastButton = currentButton;
if (ledpwmLevel > 255) ledpwmLevel = 0; fanpwmLevel = analogWrite(ledPin, ledpwmLevel);
}
|
|
|
|
|
13
|
Using Arduino / Programming Questions / Re: Music Shield and Proximity Control: coding issues?
|
on: June 12, 2012, 12:21:12 pm
|
|
Ok, big update. Using the Play() function as it was would have not allow me to just play a file, as that function never returns. I have written a new one (JPlay) and now it works much better. I can now get the patch to run as many times as I want... everytime the distance sensor goes over the threshold the file play for all it's length.
Now, would be good to write something to avoid the file to play twice if the person remains in front of the sensor. Is this clear enough? or should I try explain it differently?
first attempt which doesn't work (it plays the file when something is close to the sensor, but it will play it twice if the sensor is still covered)
#include <avr/io.h> #include "config.h" #include "filesys.h" #include "player.h" #include "vs10xx.h" #include "record.h" #include <SoftwareSerial.h> SoftwareSerial mySerial(2, 3); //pin2-Rx,pin3-Tx(note: pin3 is actually later used as volume down input)
const int analogPin = A5; const int ledPin = 0; const int threshold = 300;
int sensor = A5;
void setup() { Serial.begin(9600); InitSPI(); InitIOForVs10xx(); InitIOForKeys(); InitIOForLEDs(); InitFileSystem(); Mp3Reset(); }
void loop() {
//Serial.println("loop"); Serial.println(analogRead(analogPin)); int pippo = 1;
while (analogRead(analogPin) > threshold) { Serial.println("paperino"); if (pippo = 1) { JPlay(); pippo = 0; }
} }
|
|
|
|
|
15
|
Using Arduino / Programming Questions / Re: Music Shield and Proximity Control: coding issues?
|
on: June 11, 2012, 08:50:05 am
|
Yes that's make sense. That's also why the Music Shield is not using them I guess.. My problem is still there though. Anyone? This seems to be the function I have to use, but I am not really sure how to read this reference.. http://code.google.com/p/musicshield/source/browse/branches/arduino+code/music/player.cppvoid Play() { playingState = PS_NEXT_SONG; currentFile = 1; //cyclely play while(1) { //CheckPlay(); //CheckKey(); AvailableProcessorTime(); if(1 ==playStop) { if(OpenFile(currentFile)) { //if open failed, then try it again if(OpenFile(currentFile)) { playStop = 0; playingState = PS_NEXT_SONG; currentFile = 1; continue; } } PlayCurrentFile(); if (playingState == PS_PREVIOUS_SONG) currentFile--; if (playingState == PS_NEXT_SONG) currentFile++; if (currentFile==0) currentFile = 1; //if (playingState == PS_END_OF_SONG) playingState = PS_NORMAL; Mp3SoftReset(); } } }
|
|
|
|
|