Show Posts
Pages: 1 2 [3] 4 5
31  Using Arduino / Programming Questions / Re: counter don't count on: September 18, 2012, 07:17:06 am
Thanks for answers.
That was what I need: a changing-mind-hint...(I believe it isn't good english. smiley-red)

The sensor (line-tracer-sensor DFRobot)gives a stable analog value at 0 and 1006. So I used it on an analog port.
But now I put it in an digital-port and Arduino recognized it as HIGH and LOW.

It works fine now.

Thanks...

Johan
32  Using Arduino / Programming Questions / Re: counter don't count on: September 18, 2012, 06:16:19 am
Yes, I've thought of this thing too.
I think: the variable signal can be HIGH or LOW. So I named it a boolean. But I understand boolean is a function who give feedback a 0 or 1.

But when I changed to

int signal = 0;

counting even don't working...

Or is the problem that digitalRead only can read out a pin? And not a variable?

How can I readout the HIGH- or LOW state of an variable?

Johan
33  Using Arduino / Programming Questions / counter don't count on: September 18, 2012, 05:29:24 am
Hi,
I try to count a HIGH / LOW state of a signal.
The parts of the code (analog signal to digital signal) works.
Count-part in another sketch (standard arduinosketch ButtonStateChange) works
But in the total sketch the count-part don't work.

Anyone an idea? (of course... i'm still a very newbee...)
Below the code

Gr.
Johan

Code:
boolean signal;
int sensorvalue;
int signalCounter = 0;   // counter for the number of button presses
int signalState = 0;         // current state of the button
int lastsignalState = 0;     // previous state of the button

void setup(){
  Serial.begin(9600);
}

void loop(){

  sensorvalue = analogRead(A0);
  signalState = digitalRead(signal);

  if (sensorvalue == 1006){
    signal = HIGH;
  }

  if (sensorvalue == 0){
    signal = LOW;
  }
  if (signalState != lastsignalState) {
    if (signalState == HIGH) {
      signalCounter ++;
    }



    lastsignalState = signalState; 
  }
  Serial.print(sensorvalue);
  Serial.print(",");
  Serial.print(signal);
  Serial.print(",");
  Serial.println(signalCounter);
  delay(500);
}


34  Using Arduino / Programming Questions / Re: Random on: June 13, 2012, 03:59:31 am
Thanks all.
It's working for the purpose we want.
And yes, it's a strange design, but we have no time to make it better.
(pupils always start to late with their projects...)

Gr.
Johan
35  Using Arduino / Programming Questions / Random on: June 13, 2012, 02:52:41 am
Hi,

I try to turn on max 5 leds by pressing 2 buttons.
For this I used this script below.
But, after reset, the most time the same led is beaming.

Is there any improvement on it?

Gr.
Johan

Code:
int led[] = {3,4,5,6,7,8};
int numberLeds = 6;
int button1 = 9;
int button2 = 10;
 
void setup() {               
  for (i=0;i<5;i++){
    pinMode(led[i],OUTPUT);
    digitalWrite(led[i],LOW);
  }
  pinMode(button1,INPUT);
  pinMode(button2,INPUT);
}
 
void loop() {
  randomSeed(analogRead(0));
  if (digitalRead(button1)&&digitalRead(button2)){
    if(random(100)>50){
      digitalWrite(led[random(numberLeds)],HIGH);
    }
    if(random(100)>50){
      digitalWrite(led[random(numberLeds)],HIGH);
    }
    if(random(100)>50){
      digitalWrite(led[random(numberLeds)],HIGH);
    }
    if(random(100)>50){
      digitalWrite(led[random(numberLeds)],HIGH);
    }
    if(random(100)>50){
      digitalWrite(led[random(numberLeds)],HIGH);
    }
    while(true){
      delay(1000);
    }
  }
}
36  International / Nederlands / Re: arduino en robotics onderdelen - favo shops in BE en NL ? on: April 19, 2012, 05:32:05 am
Ik mis Farnell nog in dit rijtje. Enorme keus aan elektronica componenten. Zelfs ook wat arduino spulletjes.
Voor scholen en bedrijven werkt deze firma zonder verzendkosten.
Dus of het nou een onderdeeltje is van 10 eurocent of 100 euro, de volgende dag heb je 't binnen.

Goede site ook met veel filter mogelijkheden (moet ook wel...).

Aanbevolen.

http://nl.farnell.com

Groet,
Johan Nijsse
37  Using Arduino / Installation & Troubleshooting / Re: POP-BOT Inex upload trouble on: March 20, 2012, 10:03:57 am
Works!
Fine, thank you.

Gr.
Johan
38  Using Arduino / Installation & Troubleshooting / POP-BOT Inex upload trouble on: March 20, 2012, 03:42:47 am
Hi,

We're using a INEX POP-BOT (with Arduino POP-168 -> Board have to set on Arduino Mini).
And suddenly, after fine using, it don't upload. Arduino gives the mean error: avrdude: stk500_getsync(): not in sync: resp=0x00 etc.

What happened?

The usb cable works fine, device manager gives no trouble, the POP-BOT itselfs works fine with the program that was upload at last. But it don't upload again.

Is there any manner to give a deep reset? Or have the pupils (we use them at school) faked the bootloader?

Anyone experience with this robot?

Gr.
Johan

39  Using Arduino / Programming Questions / Re: switch/case on: December 16, 2011, 07:24:20 am
Yes, I read a voltage of the resistor.

With the if-solution:
Have i write it like this:

if (wind_direction >= 25 && wind_direction <= 35) {
  Serial.print("ZW");
}
if (wind_direction >=40 && wind_direction <=50) {
  Serial.print("W")
}
...and this twelve times?
40  Using Arduino / Programming Questions / Re: switch/case on: December 16, 2011, 07:10:09 am
Yes, we do in the first time.
But we have twelve situations (its a winddirectionflag, contacted with reedcontacts and different resistors).
So, i thought, the if-solution became a long code.

J.
41  Using Arduino / Programming Questions / switch/case on: December 16, 2011, 06:58:42 am
Hello,

I had the following code (not complete):

switch (wind_direction)
{
  case'30':
  Serial.print("ZW");
  break;
}

Is it possible to define the '30' as a value of 25 - 35?
The value 30 is in some circumstances a little bit lower or higher, but in all this range he must Serial.print("ZW").

Ideas?

Gr.
Johan
42  Using Arduino / Motors, Mechanics, and Power / Re: control a continuous rotation servo on: December 07, 2011, 09:48:11 am
Thanks for answering.
Indeed it's possible to use this servo.
I pinned myself too much to the idea of an example of what I read.
This is an eyeopener. Thanks.
43  Using Arduino / Motors, Mechanics, and Power / control a continuous rotation servo on: December 07, 2011, 02:53:03 am
Hi,

Is it possible to control a 'continuous rotation servo' (parallax) like as a normal servo?
I mean: can this servo stay in different positions?
Normally this servo turns left or right with a specified speed.
A normal servo takes 120 degrees of rotation, so the sensor can't have a look behind himself.

The project is this:
A heat-sensor turns around and looks at different positions if it is heat or not.
At the heatest position it put a lot of water on it. (like an automatic fire fighter)

Gr.
Johan
44  Using Arduino / Programming Questions / Re: a long loop on: November 29, 2011, 07:34:24 am
Quote
but certainly you can put the voltage test code in a function, and call it often from the morse() function

Possibly it's a good idea.
But when the voltage check gives reason to another action, the morse() must be break out?

I shall ask the boys for a exact description of the actions depending on the voltages.
45  Using Arduino / Programming Questions / Re: a long loop on: November 29, 2011, 07:29:12 am
Quote
"It" is a function, not a void. How would you describe "it" if its return type was int?
Sorry, you're right. I'm still a very beginner in this world.

Here's the code (it's a code from pupils who make their final workpaper at a secondary education school, and I see in the morse() they haven't adjust the comments...):

Code:

int LED_sein = 12;
int LED_baken = 10;
int LED_top = 9;
int LED_knipper = 5;
int LED_gevaar = 2;
int Spanning_batt = 0;
int Spanning_motor = 0;
int Spanning_grens = 409;
int Spanning_grens_altijd = 245;
int Spanning_grens_varen = 347;
int Spanning_grens_knipper = 491;


void setup () {
  Serial.begin(9600);          // setup serial
  pinMode (LED_sein, OUTPUT);
  pinMode (LED_baken, OUTPUT);
  pinMode (LED_top, OUTPUT);
  pinMode (LED_knipper, OUTPUT);
  pinMode (LED_gevaar, OUTPUT);
}

void loop() {
  Spanning_batt = analogRead(A0); //leest batterijspanning
  Spanning_motor = analogRead(A1); //leest motor spanning uit
  Serial.print(Spanning_batt);
  Serial.print(",");
  Serial.println(Spanning_motor);

  if (Spanning_batt < Spanning_grens) {
    gevaarlicht();
    morse();
  }
  else {
    digitalWrite (LED_sein, LOW);
    digitalWrite (LED_gevaar, LOW);
  }
  if (Spanning_motor > Spanning_grens_altijd) {
    baken();
  }
  else {
    digitalWrite (LED_baken, LOW);
    digitalWrite (LED_top, LOW);
  }
  if (Spanning_motor > Spanning_grens_varen) {
    varen();
  }
  else {
    digitalWrite (LED_knipper, LOW);
  }
  if (Spanning_motor > Spanning_grens_knipper) {
    knipper();
  }

}
void baken() {
  digitalWrite(9, HIGH); //zet top en hek licht aan
  digitalWrite(10, HIGH); //zet bak en stuurboord licht aan
}
void varen() {
  digitalWrite(5, HIGH);
}
void knipper() {
  digitalWrite(5, HIGH);   // set the LED on
  delay(1000);              // wait for a second
  digitalWrite(5, LOW);    // set the LED off
  delay(1000);              // wait for a second
}
void gevaarlicht() {
  digitalWrite(2, HIGH);
  delay(2000);
}
void morse() {
  digitalWrite(12, HIGH);   // set the LED on
  delay(700);              // wait for a second
  digitalWrite(12, LOW);    // set the LED off
  delay(1000);              // wait for a second

  digitalWrite(12, HIGH);   // set the LED on
  delay(200);              // wait for a second
  digitalWrite(12, LOW);    // set the LED off
  delay(200);              // wait for a second
  digitalWrite(12, HIGH);   // set the LED on

And this morse() is going on about 2 à 3 minutes.
But  while this code runs, the voltages must be controlled...

I think there are more mistakes in the code, but the pupils must do it further..
Pages: 1 2 [3] 4 5