Show Posts
|
|
Pages: 1 2 3 [4] 5
|
|
47
|
Forum 2005-2010 (read only) / Syntax & Programs / Function for multiple blinking led
|
on: June 29, 2009, 02:06:36 am
|
|
I need help, i'm trying to blink multiple leds with one simple function within the .pde. Timer only, no delay. I want two states for each led, millis ON and millis OFF. The code i did is not working like it suppose to.
void flashled(int ledpin, int ledON, int ledOFF)
I tried with an array and it did not work well either. Must be a simple way to get this works.
Thanks.
long time = 0; long timeON = 0; long timeOFF = 0; int state = LOW;
void setup() { Serial.begin(38400); pinMode(10, OUTPUT); pinMode(11, OUTPUT); pinMode(12, OUTPUT); }
void loop() { flashled(10, 1000, 500); flashled(11, 500, 1000); flashled(12, 500, 500); }
void flashled(int ledpin, int ledON, int ledOFF) { time = millis(); if (state == HIGH) { if (time >= timeOFF) { state = LOW; //Serial.print(state); digitalWrite(ledpin, state); timeON = timeOFF + ledOFF; } } else { if (state == LOW){ if (time >= timeON) { timeON = millis(); state = HIGH; //Serial.print(state); digitalWrite(ledpin, state); timeOFF = timeON + ledON; } } } }
|
|
|
|
|
48
|
Forum 2005-2010 (read only) / Syntax & Programs / Help with Parse split delimited string in c++
|
on: June 12, 2009, 06:02:11 pm
|
Hello everyone How to make this code working in Arduino sketch ? #include <string> #include <vector> #include <functional> #include <iostream> using namespace std; void split(const string& s, char c, vector<string>& v) { string::size_type i = 0; string::size_type j = s.find(c); while (j != string::npos) { v.push_back(s.substr(i, j-i)); i = ++j; j = s.find(c, j); if (j == string::npos) v.push_back(s.substr(i, s.length( ))); } } int main( ) { vector<string> v; string s = "Account Name|Address 1|Address 2|City"; split(s, '|', v); for (int i = 0; i < v.size( ); ++i) { cout << v << '\n'; } }
|
|
|
|
|
51
|
Forum 2005-2010 (read only) / Français / Re: LED extérieure directement sur pin13
|
on: August 17, 2009, 02:14:25 am
|
On dit dans tous les documents que j'ai pu voir sur le net et même sur le site officiel que la sortie digitale 13 est spéciale dans le sens où on peut brancher directement une LED sans sa résistance de limiation d'intensité habituelle à cause de la résistance intégrée sur le circuit est servant aussi à la LED témoin As-tu un lien sur ce que tu écris ? Je ne savais pas. C'est étrange entoucas.
|
|
|
|
|
53
|
Forum 2005-2010 (read only) / Français / Démarer un Arduino avec un pin
|
on: August 06, 2009, 06:24:44 am
|
|
J'ai un projet avec seulement un bouton. Il fait tout les fonctions que j'ai besoin, press/hold/press-press etc... ça c'est pas trop compliqué en utilisant les timers. Je veux aussi pourvoir démarrer/éteindre le Arduino avec ce même bouton, je ne sais pas comment m'y prendre. Probablement que le Arduino doit-être tout d'abord en sleep ou autre état de ce genre ?
Merci de me donner un petit coup de main.
|
|
|
|
|
56
|
Forum 2005-2010 (read only) / Interfacing / Re: Piezo / buzzer without Arduino
|
on: August 12, 2009, 12:02:35 pm
|
|
Hey cool stuff there, i'm gonna need it for another project soon. But for now, i just need a simple beep sound but nice and warm, you know like the beep sound in your popular small electronic devices. I wish i could use one Arduino PWM pin and trigger/modulate the 555 ic and produce a variety of nice beep sound on purpose. :-/
Again, i can't use Arduino to produce the wave because he is already running other task and the wave sounds ugly that is why i need something external like the 555.
|
|
|
|
|
59
|
Forum 2005-2010 (read only) / Interfacing / Piezo / buzzer without Arduino
|
on: August 04, 2009, 02:10:28 pm
|
|
I'm looking for a simple way to drive a Piezo/buzzer without the Arduino. I will trigger the piezo state (ON/OFF) from an Arduino digital pin but the square wave wont be generated by the Arduino. Is there a simple schematic out there for that ?
Thanks!
|
|
|
|
|