Show Posts
Pages: [1] 2 3 ... 88
1  Using Arduino / Programming Questions / Re: Morse Code lights problem with delay and organization on: September 27, 2014, 06:53:41 am
My understanding is that the delay is holding that command for a certain amount of time in milliseconds.
Yes. I was asking, because you wrote "holding on a little too long " - so one simply adjusts the delay. As you know that, I am now wondering f you asked something else and I misunderstood the question.

is byte pin the name of the pin in this case?
Yes. specifically when you write a function the first word (void in this case) says what the function returns (like digitalRead() returns something, but delay() does not). Void means we are not returning anything. Then comes the name of the function, we used "dit" as the example. Inside the brackets you can zero, one or many arguments. Here we have one. For each argument you need two words, the first is the type ( byte, char, long ...) the second word is the name you want to use.

For all the other neat ways to use functions in C or C++ read some tutorials, books or google.

And yes, I can think of plenty of ways to improve and reorganize the code, but you can do this one thing at a time, gradually as your knowledge gets better, and still have a working device. at all intermediare stages. One note of "warning"(?) - the use of delay() limits this device, it will need a different approach if you want to read buttons or otherways make it interactive.  Keep up the good hobby !
2  Using Arduino / Programming Questions / Re: Morse Code lights problem with delay and organization on: September 22, 2014, 04:06:14 pm
I'm having trouble with the lights holding on a little too long on the HIGH and LOW
It is OK to be new and asking simple questions. I have to answer by asking a question though - what do you think the number inside the delay() is doing, and what happens if you change it?

Also, I know there has to be an easier way to write this all out, at least a more condensed form
Oh yes there is. It is called writing your own function. Your comments nicely say "dah" and "dit"  - so that is what we want: A function that does a "dah" and one for "dit".
void dahr1() { // dah for r1
digitalWrite(r1, HIGH);
  delay (400);  
Then you do all 8 combinations on & off combinations... and your main code (we'll skip the other error(s), as PausS already has pointed that one out) simple becomes
ditr1() ; spcr1(); ditr1() ; spcr1(); dahr1() ; wrdr1() ;
and so on.  

I'd optimize that as there must be some space after every dit or dah, and include that in the dit and dah functions. As the word-space always will follow a characterspace, we can just add the etra as the word space.

Lastly, there is no need to write one set of functions for r1 and on set of function for r2. After all, there is only one digitalWrite() and it is good for all pins - you include which pin is written to. The same with your dit and dah function. The syntax for inclduiog this in your own functions is
void dit(byte pin) {
  digitalWrite(pin,HIGH) ;
  delay(200) ;  // Dit
  delay(200);  // small space
And now you only have a dit, dah and wrd - only 3 functions. Your main code simplifies to
dit(r1); dah(r1); wrd(r1);
and so on. You can write a whole morse character on one line.
3  Community / Exhibition / Gallery / Re: It Woiks! on: September 21, 2014, 12:26:41 pm
Looking at your previous posts, it has been an exciting journey for you - and the finished project is noce. There is no such thing as "simple" - your project may be too advanced for others on this forum. If you as an indvidual feel proud of it, then it is indeed a good project.

Even so, I sincerley think it is a good project. You completed it, nice looking box an all. Now, the litmus test: Is it being used when you play a board game that requires a die or pair of dice smiley ?
4  Using Arduino / Project Guidance / Re: Stepper motors and delay command on: September 14, 2014, 03:04:00 pm
probably fails, you should write
- the "L" makes sure the compiler does not reduce it to an int. (You may want to add a comment // 7minutes wait - for clarity)

I do not understand "because the power go off while using delay ()".

Are you asking for what to do if the power dies "unexpectedly"? Then look at EEPROM to write your Step value into the first 4 memory bytes, and retrieve this value on power up.

Or is something in your driver electronics shutting power down after inactivity? In that case there is little you can do in the program
5  Using Arduino / Programming Questions / Re: The Software Servo Library issues with example code provided on: September 13, 2014, 01:51:07 pm
OK, the flaw escapes me, too.

When you say "refuses to accept any more input", are you saying that your debug version shows that you never enter the case'0'..'9' ? Or that the servos never move? If you enter ABA do you get ABA return?

I am not familiar with the SoftwareServo library, so I am assuming it behaves the same way as the hardware servo library. Have you tried the "normal" servo library?
6  Using Arduino / Project Guidance / Re: Thoughts on how to set this clock I made (single LED clock) on: September 11, 2014, 04:14:30 pm
I made a a onehand clock out of an amperemeter .... and had the same issue.

 Input a a single button. a short press just activates the display mode and the long push activates the time setting mode.

You push on the button until the hours match, then make a pause, then push the button until the minutes match. (actually done in 4 stages, one for each digit) When you do not push the button the system reverts to time display.
7  Using Arduino / Project Guidance / Re: Driving Motors with RPM control. on: September 11, 2014, 03:51:10 pm
Why have you pinMode()s for pins 9 and 10 and digitalWrite()s for pins 8 and 9 - especially as none of them is doing anything.
Probably the brake/enable pins of the board. Still, code should use the same pins smiley

presume stepper.step(10000) causes the motor to move 10000 steps or 50 revolutions.

Does stepper.step() block until all the moves are done?
Yes it moves 10000 steps. IF the step value given in the initialisation is correct, then that is 50 revolutions.

step() is a blocking function.

Ace67aod: When you say you change the speed, are you trying to make it go faster? Because I do not think it will do. The step speed is set to 300 - that is RPM - ( => 5 rps * 200 steps => 1 Khz step rate ) so it is done in 10 seconds, and is possible for a good stepper (&driver). Dead start/stop without acceleration is limiting it, too. Try only 200 steps at 6 rpm - ie 10 seconds to do one revolution. Does it do that exactly?

I wonder how you change the speed. Read the pot value, map it, call setspeed()?.  If all you want is "rpm" and not positional control, then use a DC motor (with or without gearing) and control it with a single PWM outputpin and analogWrite.
8  Using Arduino / Project Guidance / Re: Driving Motors with RPM control. on: September 10, 2014, 05:36:04 pm
this seems like a position control type of POT
I can NOT think of a potentiometer (assuming this what is meant when you write POT) that is NOT a position device - ie position of knob is a resistance value which usually is set up so it provides a voltage proportional to the position. What you do with the volatge is another thing - regulate a light intensity, speed of a motor, position of a stepper or servo, volume of the music, pitch ofa note ...

however the movement is choppy
could have two causes. The first is a pot is usually "noisy", ie the when you move it a little bit the resistance goes to high, to low, just right to low ... if you are controlling -f.ex - a light or music volume this is usually not evident. Depending on how you write the program it will show up as a jerky motor movement. A bit more software (running average) will fix that. The other possible cause is that your program or wiring is wrong, ie it just happens to work almost. (No shame there, we all learn better from our mistakes smiley ) Like a fortuitous resonance between a PWM signal width and a hobby servo .. or whatever - I am guessing/fantisizing here.

The suggestions is that you write a very simple sketch. One that just turns the motor. Then edit it to make the motor turn at a different rate. Another very simple sketch (I think it is in the examples) that echoes the pot position to Serial.print. And then you "simply" combine the two - the value from the pot is used to set the motor speed.

Feel free to post the code of any of your steps for comments (and do click the [#]-button whilst the code i s selected in the edit window - so it is put in a nice box, in proper font and format) . The same goes for the wiring - a photo of handdrawn wiring diagram is OK if you do not use Fritzing or eagle or whatever.
9  Using Arduino / Project Guidance / Re: Automatic Watering project on: September 09, 2014, 06:28:49 pm
Last post: September 08, 2014, 12:22:01 pm "Bump": Today at 02:30:50 pm
My appologies - I missed the date change.
10  Using Arduino / Project Guidance / Re: How to Rotate a Stepper Motor to Pre-Specified Degree + Delay on: September 09, 2014, 03:59:18 pm
And if someone could server my dinner, that would be great too.

Mind you, there is another section where you can ask for "professional help" - meaning you pay for it.

I have looked up the code
Well, what have you looked up? Show that and which bits do not suit you, then we can give a clue where to start modifying it to become your own code.
11  Using Arduino / Project Guidance / Re: Driving Motors with RPM control. on: September 09, 2014, 03:13:01 pm

Have you looked at the included examples in the Arduino IDE?

You do not control a stepper with the PWM signals. Any set of 2 or 4 pins will do. (depending on your stepper driver chip/Mosfet/Hbridge)

12  Using Arduino / Project Guidance / Re: Automatic Watering project on: September 09, 2014, 03:09:23 pm
Two hours -- and you're impatient. Wait at least a day before "bump"ing your thread.

PualS' comment is that you defined a prototype, where you probably intended to define a function. In the Arduino IDE, it automatically generates prototypes, so you dont need to. This is so you do not have to worry about the order of defining your functions.

It may well be the sensor reads lower values for more moisture, as longs as it notices the difference. You're not doing an absolute measurment. You just test for high value, rather than a low.

13  Using Arduino / Project Guidance / Re: Need small diodes - 0603 on: September 08, 2014, 01:41:11 pm
Tch tch ... and a moderator as well. Wouldnt this fit better in General Electronics section?  smiley-mr-green
14  International / Scandinavia / Re: Försöker bestämma mig vad jag skall använda, uppskattar verkligen hjälp on: September 02, 2014, 03:37:19 pm

Fint projekt. Det kan lösas med en vanlig Arduino, men en Mega är också fint. (Om jag nu har forståt dig). 8x8 pixlar är 24 bytes i RGBfärg256niveau. 1920x1080 är 6Mbyte. Jag antager at det bild är i et enkelt pixleformat - udpakning från JPG eller liknande vet jag intet om - men det tager en del udräkning. BMP er perfekt - 1:1 af bytes och pixlar (eller 3:1 för 24bits). Är det färg eller svart/gråt/vitt(monochrome) eller bara svart och vitt?

Från SD kortet læser du ind dit första 8x8 bild-bit (eller du skanner en 1920x1080 och letar frem dom pixlarene). Du tænder lamporna, signal til kamera  om at öppna shutter kortvarigt. (om kameraen inte vil eksponere två gånger på samme bild, hold den öppen og använd noget fremfor linsen at öppna/stänga)  Stepper mottorene snurrar til den nya position.

"Rinse and repeat" som det står på shampoo-flaska. Du gör en slinga hvor koordinaterne gås igennom.

Det tager bare et par hundrede rader Arduino kod. SD bilbliotekt vil nog fylla en del.

64 lampor kontrlleras ganska lätt med passende shiftregister som TLC5940 (4 styks). Om lampan är for stor (ström) sätt bare en transistor/mosfet imellan. Signalet er digitalt så man behöver inte tänka på analog-eletronik.

Steppermotorene driver noget mekanik, och en X/Y ram är enklast, men det kan också göras som robotarm.

Om jeg tänker på et litet 8x8 som det här så skal du flytta 2cmx1920/8=nästan 5 meter.

Som altid frågar jag aldrig VARFÖR ;-) även om jag är nyfiken. Låter som et kul projekt.
15  Using Arduino / Project Guidance / Re: G Code on Arduino? on: August 28, 2014, 02:48:37 pm
Sure. Use the Progmem feature. This allows you to store an array in the 32K Flash/Programstore. Only hassle is that you need to write it as part of your program as one long
prog_uchar Motion[] PROGMEM  = {"G1 X10 Y10;G1 Z10 E10;G1 X5 Y5 Z5 E5; ....
(here I've used the ";" as the newlinecharacter.

You can split your program into several files, so one file only holds this progmem defenition.

At this time it may occur to you that you are using 10 bytes to store two ints. So I would throw away all the Gcode interpretation and just store the XYZE values in a list of ints. Yes, the Gcode allows for floats, but you can just scale it up by (say) 10 and then only store it in inst which are tenths of millimitere. (int limits you to +/- 32000). Or you can define your own "language" and really compress/save bytes.

Then you can go sophisticated and transfer from serial port to EEprom (which though only holds 1K) so you do not need to reprogarm. Or go the whole hog and implement you falshprogramming - but that is far beyond my skills, too
Pages: [1] 2 3 ... 88