Show Posts
Pages: 1 ... 51 52 [53] 54 55 ... 81
781  Community / Website and Forum / Re: Sticky Subjects on: October 26, 2011, 05:30:22 pm
Whatever.... The wording it is not earthshattering important. Considering the sticky title is to get people to look there rather than post the same question, the words in the sticky would match the words they are most likely to look for. Here is a suggestion

Independent timing loops, example (2 LEDs blink)
782  Community / Website and Forum / Re: Sticky - Blink Two LEDs, independent, no delay on: October 26, 2011, 05:20:23 pm
The Blinky Sticky needs a cover / introduction.  Some questions the introduction may answer: What is this?  When would I use this?  @Msquare, please get us started...
Yes, well, aren't the comments enough? I agree that it makes sense to move them from comments to an intro before, just for formatting reasons. Here is a reworded "starter" (and the large leadin comment should thus be much reduced)
The Blink without Delay example explains why and how to create a timed sequence, blinking one LED, without using the delay() function, but using a millis()-"timer" instead. This example show how to extend it to two. The LEDs blink independent of each other.
(yeah, too many commas.)

I havent seen a question since the stick was "published" where I would answer it with - "look at this sticky", nor a question on "what is this". Either noone is interested or the sticky is "working" very well indeed.
783  Community / Website and Forum / Re: Sticky - Blink Two LEDs, independent, no delay on: October 26, 2011, 05:04:04 pm
I've also been coding since 1975.
Me, too. But done other stuff later, as well.
784  Community / Website and Forum / Re: Sticky - Blink Two LEDs, independent, no delay on: October 25, 2011, 01:48:17 pm
Two reasons why not.

The point of using symbolic names is that you do NOT need to know the values. That Arduino core could redefine HIGH/LOW to 22 and 120 respectivly, because it happens to work faster with some port operations or it has the right rhyme with cosmic vibes. Your code will break miserably, "ours" will work. smiley

The point of the example is to show the use of "timers" and how to timers NOT interfere with each other. Any and every "fancy" coding trick will distract from the main point.

But thanks for sharing, it was a "new" way of doing the toggle. If you look through this discussion thread you'll see we examined every statement, from all three sides smiley-wink
785  Using Arduino / LEDs and Multiplexing / Re: PWM not working correctly - pls help. on: October 24, 2011, 12:25:48 pm
I had a "HighPower" LED and it was bright even at PWM value 3. If I used an oldfashined weak indicator LED the fading worked fine, and the LED basically didnt appear lit before value 20 or so. I tried then to view the power-LED in strong light, and the dimming effect was "better".

the new poerLEDs are simply too good smiley
(NB: I havent looked at the code - the others have done that)
786  Using Arduino / Programming Questions / Re: Mystified trying to edit library routine on: October 24, 2011, 12:15:39 pm
Memory of the read/write kind, called SRAM sometimes in connection with the Arduino is a precious resource. Depending on your chip there is not much of it. On the 328 there is 2k (2048) bytes of it.

The core (basic Arduino stuff that calls the loop() handles the timers, does the serial and so on uses a few hundred bytes. The LCD library probably uses a few handfulls.

All your variables use space, and what is worse, every string you specify also resides in RAM (even though it never changes)

Your array 97*16 bytes is 1552 bytes large.

I think you have exceeded the RAM. No, there is no error message from the compiler.

Use the MemoryFree library/call to see what you have left (you first temporarily have to make it smaller). Look for the PROGMEM method for putting your large array in Flash.
787  Using Arduino / Motors, Mechanics, and Power / Re: What do the 6 wires of a stepper motor represent? on: October 20, 2011, 05:22:16 pm
It conducts current, like every other wire. smiley

Google for Stepper, preferably on Images, and look at the various pictures until you find one that looks like yours. Then look at the page it came from. If you are lucky it will contain a diagram of what colour is connected to which coil. Or maybe there is a number/model on your stepper - google that.

Basically Unipolar Stepper have 5 or 6 wires - on the 5 wire version the "middle" of the two coils goes to one wire, on the 6 wire version each "middle" is seperate. Use an Ohm metere and measure every combination of the wires. You can then work out how the wires connect to the coils.
788  Using Arduino / Programming Questions / Re: math with float not working on: October 20, 2011, 01:46:57 pm
I did a quick test, and the maths works as expected.

So "It suddenly stopped working" - the classic counter question is : What did you do ?

My best guess is that you are overflowing RAM, this usually results in weird behaviour. How large is the overall program? The size of code (~number of lines) isnt what I am asking about, but how many arrays are you using? Many strings used in print will break the ~1.5K you have. Including a library may have a large RAM-memory usage. Search for the "MemoryFree" routine and use that.
789  Using Arduino / Programming Questions / Re: PIR servo on: October 20, 2011, 01:17:37 pm
I think you should take a little more time, care and thinking. The last post included a stupid, yet simple mistake
oldStat = digitalRead(PIRSensor);
error: 'oldStat' was not declared in this scope
Becuse of a simple typo - you declared oldState(with an "e") and used it correctly everywhere else.

Hey, we all make mistakes, that is allowed. But your posts look a bit like "hey I tried a few random keypresses, it doesnt compile/work, lets toss it on the forum and see what happens."
790  Using Arduino / Networking, Protocols, and Devices / Re: New to Serial Communication. Help? on: October 20, 2011, 12:57:16 pm
The basics is that
Send the bits of the number/characters one bit at a timeSend all the bits simultaenously.
Requires only one wire (plus ground)Requires at least as many wires as you want to send bits
More wires used for clock and flow control in some systemsAlso may use some extra wires for flow, clock, reset
.Several "Parallel words" will then be sent serially
RS232, SATA, Arduino TX/RX, USB, EthernetLPT interface, IDE-disk interface
(edit added a bit about multiple parallel words)
791  Using Arduino / Programming Questions / Re: PIR servo on: October 20, 2011, 12:47:24 pm
the "[ color=red ]" stuff isnt going to help. That was to display some code in color on the web page, it is not code. Get rid of that.

Secondly it is just a matter of counting "{" and "}" - they have to match. You have too many "}"

Around line 31 you have a ";" immediatly after the "if". That ends the if statment and the following "{" is for a statement block that will always be executed. And therefor there is "lese without a "if" around line 54.

Thus, remove a "}" or two and the semicolon. Of course the logic (what executed under which conditions) is highly dependent on which "}" you remove, so think about it. Dont just wildly delete (as I did, because I only wanted to find syntax errors, not logic errors)
792  Community / Bar Sport / Re: How far would you be will to travel for a "local" electronics hobbyist shop? on: October 20, 2011, 12:09:19 pm
I'll be happy with shipping but i'm living in the country where there is NO trend or NO system for good shipping, some companies are providing now but lot more expensive so I have to go around sometimes for more than 150 or 200 miles to buy just simple few things  which I sometimes don't even find then
OK. I wont complain anymore.
793  Community / Website and Forum / Re: Sticky - Blink Two LEDs, independent, no delay on: October 20, 2011, 11:12:44 am
I take that
Time to roll the presses on this one I think.
as a "go"

As I started, I will finish. In particular I will again test functionality by actually running it. Yes it works. (I wont bother uploading a video smiley ) The deed is done.(My only worry now is a flood of PMs from people who still do not understand it)
794  Using Arduino / Programming Questions / Blink Two LEDs, independent, no delay on: October 20, 2011, 11:11:13 am
Some of the frequent contributors thought this might be a good example - for when the tutorial "Blink without Delay" example is not enough
/* Multiple independent delay - Two blinking LEDs

Working code example that blinks two LEDs, each with its own independent period.
This extends the BlinkWithoutDelay example of a single LED, showing how to
implement multiple independent timing paths in the main loop.

Written by several forum members. In public domain.  Oct 2011.

Note: works even when millis () wraps around to zero after approximately 50 days.

// Which pins are connected to which LED
const byte greenLED = 8 ;
const byte redLED = 10 ;

// Time periods of blinks in milliseconds (1000 milliseconds to a second).
// Time variable and constants are always unsigned long
const unsigned long greenLEDinterval = 555UL ;
const unsigned long redLEDinterval = 1234UL ;

// Variable holding the timer value so far. One for each "Timer"
unsigned long greenLEDtimer = 0 ;
unsigned long redLEDtimer = 0 ;

// Variable to know what the current LED state is
int greenLEDState = LOW ;
int redLEDState = LOW ;

void setup() {
  pinMode (greenLED,OUTPUT) ;
  pinMode (redLED,OUTPUT) ;
  greenLEDtimer = millis () ;
  redLEDtimer = millis () ;

void loop() {

// Handling the blink of one LED.
// First, check if it is time to change state
  if ( (millis () - greenLEDtimer) >= greenLEDinterval ) {
    // It is time to change state. Calculate next state.
    if (greenLEDState == LOW)
      greenLEDState = HIGH ;
      greenLEDState = LOW ;
    // Write new state
    digitalWrite (greenLED, greenLEDState ) ;
    // Reset timer
    greenLEDtimer = millis () ;

// The other LED is controlled the same way. Repeat for more LEDs
  if ( (millis () - redLEDtimer) >= redLEDinterval ) {
    if (redLEDState == LOW)
      redLEDState = HIGH ;
      redLEDState = LOW ;
    digitalWrite (redLED, redLEDState ) ;
    redLEDtimer = millis ()  ;

/* Other code that needs to execute goes here.
   It will be called many thousands of times per second because the above code
   does not wait for the LED blink interval to finish. */


795  Using Arduino / Programming Questions / Re: Where should uint8_t and boolean be defined? on: October 19, 2011, 04:24:26 pm
"uint8_T" ?
Its the capital T. The "standard" type uint8_t exists, the uint8_T is ....

The other compiler error is because the HDQ library you're using is not #include'ing Wiring.h. I noticed the HDQ files seemed old, so something may have changed with the Arduino IDE compile/dependencies, breaking in the newer version.

I presume yuo will be using some HDQ calls in the next version, because there is no need to include it in the blink example you gave.
Pages: 1 ... 51 52 [53] 54 55 ... 81