Show Posts
Pages: [1] 2 3 ... 12
1  International / Generale / Re: Piattaforma rotante, come fare? on: March 04, 2013, 06:07:48 pm
Ha detto a scatti quindi o un servo od uno stepper..
Diciamo che ho cercato di farmi capire, non so se ho usato le parole giuste!!

A me interessa farlo girare, fermarlo per un tempo indefinito, dare play e questo scatta di poco... 1 o 2 gradi forse sono anche troppo pochi...

Intanto vi ringrazio per le risposte. Appena ho tempo cercherò di leggere i link proposti, sperando di capirci qualcosa!

p.s. poi smonto la stampante ad aghi e posto la foto di quello che ipotizzerò come motore!  smiley-razz
2  International / Generale / Piattaforma rotante, come fare? on: February 25, 2013, 09:24:32 am
Salve a tutti. Era tanto che non tornavo in questo forum... diciamo che era anche molto che non lavoravo più con arduino!

Allora... io vorrei realizzare una piattaforma rotante che si muova a scatti di qualche grado... la domanda è: come?
Non ne capisco niente o quasi di elettronica (purtroppo)... però mi era stato suggerito di utilizzare un motore di una stampante (ho recuperato una vecchia stampante ad aghi).

La piattaforma deve girare di pochi gradi alla volta ad intervalli, non ciclo continuo. Sopra la piattaforma ci saranno delle miniature, quindi roba veramente leggera. Di conseguenza la piattaforma avrà un "raggio" di 5 cm al massimo!

Avete qualche idea/schema/link per aiutarmi a realizzare il mio progetto?!?!?!?

Grazie in anticipo! (e se non mi sono spiegato bene chiedete pure che non mi faccio problemi a spiegare di nuovo!)
3  Using Arduino / Programming Questions / Re: digitalRead and level probe sensor on: September 30, 2011, 04:50:26 am
Perfect it works! thanks! (to try it I've not used the capacitor, i've made 20 switch of value..)

p.s. the capacitor must be connect in parallel whit the probe, so it should be connect to the gnd and pin 7 right? take a wire by gnd, duplicate it (one for the probe and the other one for the capacitor), get the two wire (probe and capacitor) and reunite it before entering the pin right?
4  Using Arduino / Programming Questions / Re: digitalRead and level probe sensor on: September 29, 2011, 06:47:41 pm
I'm very low in electronic...

is correct the circuit attacched?

capacitor of wich capacity?

p.s. if I want use a resistor instead of "Arduino pin 7", in the same schema I've to connect "old arduino pin 7" to +5 and insert a resistor (of what? 1k?)
5  Using Arduino / Programming Questions / Re: digitalRead and level probe sensor on: September 29, 2011, 02:14:39 pm
Unfortunately I haven't details more than the follow link...
http://www.aquariumline.com/catalog/ruwal-galleggiante-vasca-accumulo-1224v-220v-p-2087.html

But I think that 20k could be enough...
It's better to use a pull-up or a pull-down?

p.s. can you make an example of code that use arduino pull-up?
6  Using Arduino / Programming Questions / Re: digitalRead and level probe sensor on: September 23, 2011, 08:46:55 am
Let me understand:
pull-up & pull-down resistor is simply a resistance, isn't??
And pull-up resistor (that I understand is favorite to a pull-down resistor because uses less corrent) could be abought 1,5k Omh right?

I've searched a little... and I've still some trouble...

If I've the probe level sensor (above mentionated) and I would like to use a pull-up resitor i must do like this:

Arduino ground --> probe level sensor --> Arduino pin 7 <-- resistor 1,5k <-- Arduino +5v

right? in a nutshell I have to link the end of the two circuits toghether and to connect everything to Arduino (e.g. on pin 7) ?
7  Using Arduino / Programming Questions / digitalRead and level probe sensor on: September 13, 2011, 04:24:00 am
I'm still here...
Now I've problem with the digitalRead... I've a level probe that "returns" HIGH when the water level is below the threshold else LOW...
The probe works also with 5v so I connect a wire to the 5v arduino's pin and the second wire to the pin 7

The sketch correctly recognizes when the probe is HIGH, but when the probe is LOW the sketch starts to "loop" reading LOW and HIGH when the correct value is only LOW...

here is the code and the output...

Code:
void setup(){
  bool thisVal = false, lastVal = false;
  Serial.begin(9600);
  Serial.println("Start"); 
  pinMode(7, INPUT);
 
  while(true){
    delay(50);
    if(digitalRead(7) == HIGH)
      thisVal = true;
    else
      thisVal = false;
   
     
    if(thisVal != lastVal){
      Serial.print("Probe change, now is ");
      Serial.println(thisVal ? "HIGH" : "LOW");
      lastVal = thisVal;
    }
  }
}

void loop(){
}

Start
Probe change, now is HIGH // right
Probe change, now is LOW // right
Probe change, now is HIGH // hereafter the probe is "LOW" but arduino continues to recognize changes...
Probe change, now is LOW
Probe change, now is HIGH
Probe change, now is LOW
Probe change, now is HIGH
....


p.s. I know that the if else could be
Code:
thisVal = ((digitalRead(7) == HIGH) ? true : false);
or better
Code:
thisVal = digitalRead(7);
but it's a sample code  smiley-cool
8  Using Arduino / Programming Questions / Progmem variables in a "global file" on: August 30, 2011, 06:28:07 pm
I've some PROGMEM string; I want put all of them in a file (header or source) and include that file in all the other who need the string;

I want also that the strings have a different value depending on "something", such as a # define

is a difficult thing to explain, then make a trivial example:

file.h
Code:
# ifndef file_h
# define file_h

# if defined A
  str1 = "A1";
  str2 = "A2";
# else if defined B
  str1 = "B1";
  str2 = "B2";
# else
  str1 = "C1";
  str2 = "C2";
# endif

char * arr [] = {str1, str2};
# endif

(eventually create the array in each block of the if-else; the definition of 'A', 'B' etc is made by the sketch)

unfortunately such a thing as above by an error of multiple definiton of ... although "file.h" is included only one other file ...

another soluction is to make fileA.h, fileB.h etc and include only a file in sketch, and all the file in the other who need it... but I do not know how to do...

you have any ideas?
p.s. each string is progmem
9  Using Arduino / Programming Questions / Re: Convert float and long to string to complete a LCD I2C library on: August 30, 2011, 06:14:02 pm
I need only two digit after point; so I use that code
Code:
void System::lcdPrint(float f){
print((int) f);
print('.');
if(((int) (f * 100)) % 100 < 10)
print('0');
print( ((int) (f * 100)) % 100);
}

edit: I've forgotten to sey that my float are < 100...
10  Using Arduino / Programming Questions / Re: Using system library (EEPROM) in my custom one on: August 24, 2011, 06:47:19 am
All this happens BEFORE the compiler is invoked

right! I forgot the "pre" smiley-razz
11  Using Arduino / Programming Questions / Re: Using system library (EEPROM) in my custom one on: August 24, 2011, 06:06:13 am
I've been there too... very annoying...

but, for me, the reason is that the compiler is not very efficient
12  Using Arduino / Programming Questions / Libraries and directory... on: August 24, 2011, 05:39:27 am
Can I have a directoryA which contains directoryB, directoryC, directoryD and include one of the sub directory in my sketch?
I've tried, but
Code:
error: directoryA/directoryB.h: No such file or directory
13  Using Arduino / Programming Questions / Re: freeMemory() and memory leak... on: August 12, 2011, 08:58:00 am
p.s. why do you use const char instead of prog_uchar? is prog_uchar a typedef for const char?

Unsigned char. Use the source, Luke:

Code:
typedef unsigned char prog_uchar PROGMEM;

I used it initially to see if it made a difference. Anyway I'm not totally keen on typedefs that hide minor details.

if I use prog_uchar strcpy_P gives error:
sketchName:line: error: invalid conversion from 'prog_uchar*' to 'const prog_char*'
sketchName:line: error: initializing argument 2 of 'char* strcpy_P(char*, const prog_char*)'

so even I used const char instead of prog_uchar

For strncpy_P, some time ago, I see avr/Progmem.h and I haven't see it... but thank goodness exist

for the objet... I know... but I asked to make first smiley-lol
if possible I'd like to keep source for me smiley-lol
14  Using Arduino / Programming Questions / Re: freeMemory() and memory leak... on: August 11, 2011, 04:54:17 pm
Now it's a good thing!

but why before was totally different?

I'll use strcpy_P... but... I need strncpy_P... of course doen't exist no?
if you see my code i make a control of the lenght... I'm not sure about the max len of the string... and I know what could appens if the buff len is << PROGMEM max len...

p.s. why do you use const char instead of prog_uchar? is prog_uchar a typedef for const char?

p.p.s. I know that it's not directly linked... but if I've a file.h and a file.cpp; if i create the object and i put file.h and file.o in file folder... can I compile a sketch that include file.h? or arduino gives error?
15  Using Arduino / Programming Questions / Re: escape loop after x number of blinking Led on: August 11, 2011, 07:29:04 am
the main is

Code:
main(){
  setup();
  for(;;)
    loop();
}

so loop is ever call... you can do:
Code:
int ledPin = 13;   // select the pin for the LED
int val = 6;    // variable to store the data upper limit

void setup() {
  pinMode(ledPin,OUTPUT);    // declare the LED's pin as output
  // blink the LED that number
    for(int i=0; i<val; i++) {
     digitalWrite(ledPin,HIGH);
     delay(150);
     digitalWrite(ledPin, LOW);
     delay(150);
  }
}
void loop(){
  ;
}

or
Code:
void setup() {
  pinMode(ledPin,OUTPUT);    // declare the LED's pin as output
}

void loop () {
  static bool end = false;
  if(!end){
     // blink the LED that number
     for(int i=0; i<val; i++) {
       digitalWrite(ledPin,HIGH);
       delay(150);
       digitalWrite(ledPin, LOW);
       delay(150);
    }
    end = true;
  }
}

or
Code:
void setup() {
  pinMode(ledPin,OUTPUT);    // declare the LED's pin as output
}

void loop () {
  static int i = 0;
  // blink the LED that number
  for(; i<val; i++) {
     digitalWrite(ledPin,HIGH);
     delay(150);
     digitalWrite(ledPin, LOW);
     delay(150);
  }
}

and simlilar
Pages: [1] 2 3 ... 12