Hi, Im just starting out with my Arduino, but am enjoying. Does anyone know of any courses for begineers to follow online?
I want to write a sketch that will basically, start a loop, when a button is pressed, which basically has some LEDs going on and off and dancing about, and this loop to run for 1 moinute then stop, is that simple enough to do?
I then, later down the line woudl like to change the button pressed to a motion sensor if possible, and have that triggering the loop.
boolean (8 bit) - simple logical true/false, Arduino does not use single bits for bool
byte (8 bit) - unsigned number from 0 to 255
char (8 bit) - signed number from -128 to 127. The compiler will attempt to interpret this data type as a character in some circumstances, which may yield unexpected results
unsigned char (8 bit) - same as 'byte'; if this is what you're after, you should use 'byte' instead, for reasons of clarity
word (16 bit) - unsigned number from 0 to 65535
unsigned int (16 bit)- the same as 'word'. Use 'word' instead for clarity and brevity
int (16 bit) - signed number from -32768 to 32767. This is most commonly what you see used for general purpose variables in Arduino example code provided with the IDE
unsigned long (32 bit) - unsigned number from 0 to 4,294,967,295. The most common usage of this is to store the result of the millis() function, which returns the number of milliseconds the current code has been running
long (32 bit) - signed number from -2,147,483,648 to 2,147,483,647
float (32 bit) - signed number from -3.4028235E38 to 3.4028235E38. Floating point on the Arduino is not native; the compiler has to jump through hoops to make it work. If you can avoid it, you should. We'll touch on this later. Sparkfun.
You select the 'type' best suited for your variables.
ex:
your variable does not change and it defines a pin on the Arduino. const byte limitSwitchPin = 34;
since an analog variable can be 0 to 1023, a byte will not do, you can select 'int'. int temperature;
if your variable needs to be within -64 to +64 a 'char' will do nicely. char joystick;
if your variable is used for ASCII then you need type 'char', char myText[ ] = {"Raspberry Pie Smells"};
if your variable enables some code then boolean can be used. boolean enableFlag = false;
millis() returns the time in ms since rebooting, unsigned long currentTime = millis();
etc.
Hello
Don´t hesitate to ask in case do you have issiues by the realization of you projects.
You will find many helpful people and don´t forget to post your sketch in code tags "</>".
Hi, so this is my very primitive code so far, sorry.
What I'd like is to have this loop run for 30 seconds and activated by a push button.
The idea is for it to sit on my desk and be pwoered by a battery, also is there anyway to factor in a power safe mode at all to try and save power?
Thank you!
D
/*
Blinking LEDs - test program to run 3 LEDs in a pattern of blinks
*/
int led1 = 12;
int led2 = 11;
int led3 = 10;
int led4 = 9;
int led5 = 8;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(180); // wait for 1/2 a second
digitalWrite(led1, LOW); // turn the LED off by making the voltage LOW
digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(180); // wait for 1/2 a second
digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW
digitalWrite(led3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(180); // wait for 1/2 a second
digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW
digitalWrite(led4, HIGH); // turn the LED on (HIGH is the voltage level)
delay(180); // wait for 1/2 a second
digitalWrite(led4, LOW); // turn the LED off by making the voltage LOW
digitalWrite(led5, HIGH); // turn the LED on (HIGH is the voltage level)
delay(180); // wait for a second
digitalWrite(led4, HIGH); // turn the LED off by making the voltage LOW
digitalWrite(led5, LOW); // turn the LED on (HIGH is the voltage level)
delay(180); // wait for 1/2 a second
digitalWrite(led3, HIGH); // turn the LED off by making the voltage LOW
digitalWrite(led4, LOW); // turn the LED on (HIGH is the voltage level)
delay(180); // wait for 1/2 a second
digitalWrite(led2, HIGH); // turn the LED off by making the voltage LOW
digitalWrite(led3, LOW); // turn the LED on (HIGH is the voltage level)
delay(180);
digitalWrite(led1, HIGH); // turn the LED off by making the voltage LOW
digitalWrite(led2, LOW); // turn the LED on (HIGH is the voltage level)
}
Hello
Well, I think this is a school assignment published several times. Take some time and search in the forum. Don't the teachers have any new ideas?
Think of a solution without delay(), sooner or later a button will surely be added.
the chance to find an online-tutorial that is doing exactly your wished program-behaviour is very low.
Of course there are demo-codes and tutorials for similar things.
Just taking an example-code and trying to modify it without knowing the basics of programming is like shooting in the fog.
So to have some basic generalised knowledge about coding for arduinos is very good.
This is what this tutorial is doing:
Take a look into this tutorial:
It is easy to understand and has a good mixture between explaining important concepts and example-codes to get you going. So give it a try and report your opinion about this tutorial.
Oh is it? I'm a 49 year old man trying to learn something new lol
Yes I think I need to produce this first step with delay but having trouble understanding adding multiple LEDs and combing their timings but I'll get my head around it eventually
ah come on your brain-age is just short beyond highest performance. ;-))
I think you are better than "the ideal candidate for this tutorial"
(which is somebody who has never done anything with computers before)
best regards Stefan
So, my effort here using the blink without delay isnt working;
is there anytjing wrong int he code?
Or....is it do to with my circuit? but the circyit works on the previous code I posted with delay.
// SETTING PIN NUMBER
int GREEN = 12;// the number of the LED pin
// THIS WILL CHANGE
int LAMPSTATE = HIGH;
unsigned long previousMillis = 0;
// constants won't change:
const long interval = 1000;
void setup() {
// set the digital pin as output:
pinMode(GREEN, OUTPUT);
}
void loop() {
// here is where you'd put code that needs to be running all the time.
// check to see if it's time to blink the LED; that is, if the difference
// between the current time and last time you blinked the LED is bigger than
// the interval at which you want to blink the LED.
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
// if the LED is off turn it on and vice-versa:
if (LAMPSTATE == HIGH) {
LAMPSTATE = LOW;
} else {
LAMPSTATE = HIGH;
}
// set the LED with the ledState of the variable:
digitalWrite(GREEN, LAMPSTATE);
}
}
Ahhh yes O suppose it coudl be described as that - but its for an old aircraft indicator lamp i picked up off ebay - thought it woudl be cool to learn on and have on my desk
yes so my other thought is that, does any of this make a difference...?
The nano board is being used to ground the earth to connect the circuit, does that make sense? the circuit worksif i use the delay sketch, without touching the circuit
There are 5 rows of 4 LEDS in 12, 11, 10 , 9 , and 8 so in theory any should work, but it's going to an array as they are being driven by anothr power source, so the grounds are completing the circuit, i hope this make sense lol
I've created some Frankenstein of a circuit probably
I changed the IO-pin-number from 12 to 13 this means that the onboard-LED of an arduino Uno is switched on off. Your sketch works as expected one second LED on one second LED off
Do you have multiple microcontrollers connected to your computer?
If you flash the code (upload the code) what is the message you see after falshing hast finished?