Recent Posts

Pages: 1 2 [3] 4 5 ... 10
Deutsch / Re: RCSwitch Library RAW Daten...
Last post by roko5049 - Today at 12:04 pm
Danke, danke danke!!!!
War gerade dabei die die Steckdosen zurück zu senden xD
Programming Questions / Re: Servo Programming Help
Last post by PaulS - Today at 12:04 pm
Code: [Select]
while (buttonState == LOW) {
    myservo.write(173);              // tell target to go to position not viewable
    randomSeed(millis()); //specifies unit for time function

  delay(random(3000,10000)); //delays a random time between 3 and 10 seconds

  myservo.write(97); // target goes to viewable position

  delay(4000); // target stays in position for certain amount of time


If you ever do press the switch, you are f**ked, as this while loop has NO way of ending.

The randomSeed() function should be called ONCE, in setup(), NOT in loop(), and not over and over.

If you want to break out of this while loop if a switch is (or becomes) pressed, feel free to actually read the state of the switch in the loop.
K, how about now?
   if (switch,HIGH)

  else (switch,LOW)
Hi everybody,

my 11 yo son is working on a project of getting is bot to follow a line and at the end of the line, it should stop, scan for an object (in this case a soda can) and push it..

he managed to get the code for the line following (including the 5 sec countdown with leds etc) and he has the code for scanning for objects within the correct distance and then push it but we have no idea on how to merge the 2... my idea was that when the bot does not see a line for like 1 second, it would stop and the other command would start but i am clueless as how to write the code... my son is gone on a fieldtrip for a week so he cant help... i put the code below? is there anybody who can come rescue me before my boy is back and laughs at me? :-)

code for line following:

#include <Wire.h>
#include <Zumo32U4.h>

// This is the maximum speed the motors will be allowed to turn.
// A maxSpeed of 400 lets the motors go at top speed.  Decrease
// this value to impose a speed limit.
const uint16_t maxSpeed = 250;
Zumo32U4Buzzer buzzer;
Zumo32U4LineSensors lineSensors;
Zumo32U4Motors motors;
Zumo32U4ButtonA buttonA;
Zumo32U4ButtonB buttonB;
Zumo32U4LCD lcd;
Zumo32U4ProximitySensors proxSensors;

int16_t lastError = 0;

#define NUM_SENSORS 5
unsigned int lineSensorValues[NUM_SENSORS];

// Sets up special characters in the LCD so that we can display
// bar graphs.
void loadCustomCharacters()
 static const char levels[] PROGMEM = {
   0, 0, 0, 0, 0, 0, 0, 63, 63, 63, 63, 63, 63, 63
 lcd.loadCustomCharacter(levels + 0, 0);  // 1 bar
 lcd.loadCustomCharacter(levels + 1, 1);  // 2 bars
 lcd.loadCustomCharacter(levels + 2, 2);  // 3 bars
 lcd.loadCustomCharacter(levels + 3, 3);  // 4 bars
 lcd.loadCustomCharacter(levels + 4, 4);  // 5 bars
 lcd.loadCustomCharacter(levels + 5, 5);  // 6 bars
 lcd.loadCustomCharacter(levels + 6, 6);  // 7 bars

void printBar(uint8_t height)
 if (height > 8) { height = 8; }
 const char barChars[] = {' ', 0, 1, 2, 3, 4, 5, 6, 255};

void calibrateSensors()

 // Wait 1 second and then begin automatic sensor calibration
 // by rotating in place to sweep the sensors over the line
 for(uint16_t i = 0; i < 120; i++)
   if (i > 30 && i <= 90)
     motors.setSpeeds(-200, 200);
     motors.setSpeeds(200, -200);

 motors.setSpeeds(0, 0);

void setup()
 // Uncomment if necessary to correct motor directions:



 // Play a little welcome song">g32>>c32");

 // Wait for button A to be pressed and released.
 lcd.print(F("Press A"));
 lcd.gotoXY(0, 1);
 lcd.print(F("to calb"));


 lcd.print(F("Press B"));
 lcd.gotoXY(0, 1);
 lcd.print(F("to start"));

  // Turn the LEDs on.

 // Wait for a second.

  // Turn the LEDs off.
 // Turn the LEDs on.

 // Wait for a second.
 // Turn the LEDs off.
 // Turn the LEDs on.

 // Wait for a second.

 // Turn the LEDs off.

 // Turn the LEDs on.

 // Wait for a second.

  // Turn the LEDs off.
 // Turn the LEDs on.

 // Wait for a second.
 // Turn the LEDs off.


void loop()
 // Get the position of the line.  Note that we *must* provide
 // the "lineSensorValues" argument to readLine() here, even
 // though we are not interested in the individual sensor
 // readings
 int16_t position = lineSensors.readLine(lineSensorValues);

 // Our "error" is how far we are away from the center of the
 // line, which corresponds to position 2000.
 int16_t error = position - 2000;

 // Get motor speed difference using proportional and derivative
 // PID terms (the integral term is generally not very useful
 // for line following).  Here we are using a proportional
 // constant of 1/4 and a derivative constant of 6, which should
 // work decently for many Zumo motor choices.  You probably
 // want to use trial and error to tune these constants for your
 // particular Zumo and line course.
int16_t speedDifference = error / 4;

 lastError = error;
 // Get individual motor speeds.  The sign of speedDifference
 // determines if the robot turns left or right.
 int16_t leftSpeed = (int16_t)maxSpeed + (speedDifference + 20);
 int16_t rightSpeed = (int16_t)maxSpeed - (speedDifference + 20);

 leftSpeed = constrain(leftSpeed, 0, (int16_t)maxSpeed);
 rightSpeed = constrain(rightSpeed, 0, (int16_t)maxSpeed);

 motors.setSpeeds(leftSpeed, rightSpeed);

second code following

Bar Sport / Re: [OT ITA] Lo spamm bar
Last post by Etemenanki - Today at 12:00 pm
Si, l'avevo capito (anche perche' l'avevi citata :D) ... ma non c'era solo la 78 fanteria d'assalto, ad usare quel nome, anche se era la piu famosa ... c'erano altre truppe con "sturm" (assalto) nel nome, intendo ...
Well to be honest, I don't know the torque requirements. I'm not an engineer admittedly, but most Motors I've found locally have way too many rpms for what I'm trying to do. I guess here's some more detail.

Often I'm shooting on a macro lens at 180mm, so super close up on the watch where half the dial can cover the frame, (I'm not always shooting it that way) but because I'm so close up the watch, it will show the tiniest fatigue that human hands can give as I'm sure you all know, no one can keep their hands completely still. You'd have to be dead or a rock.

I shoot in high speed slow motion sometimes, but when it comes to the face of the watch, the watch designers don't like to see the second hand ticking in slow motion as that's not how it ticks in real time.

So my thought was to hook up regular hobby motors on a potentiometer and and slow it down, but as I said, everything that I'm finding (without ordering on the internet) is like 50,000rpmish and up.

So I saw the stepper Motors which looked like they were able to slow down to a considerable speed (just eye balling via youtube) and decided on those. And if I have to add gears, not a big deal.

Here's another factor, I have to be able to stretch the watch so that the straps and movement appear flat. I don't have to see the very top buckle, or the very bottom of the bottom strap, so my plan was to clamp those areas and stretch the watch out. It doesn't require a lot of tension as the straps we use are brand new and for the most part lay flat by themselves. But if you have ever held a watch up with your bare hand, pinching the buckle with your fingers in one hand only, you'll notice the weight of the Movement, pulls the bottom of the movement backwards and not straight up and down.

Again guys, really new to this. But here's a video I found (don't have to watch all of it, maybe 40 seconds will do) but this is how I'd like both Motors to react, only difference from this video and my build is that I want two stepper Motors with one running in reverse.

You might want to up your view of MBAM a bit....It covers way more than just  "less dangerous but still irritating stuff"

Project Guidance / Programming an odometer (a way...
Last post by eecs124 - Today at 11:59 am
Hello all,

I need to code an odometer (a way to determine the position of a robot) from scratch. I am using an Elisa-3 robot (information about it can be found HERE).

The specs of the robot state that a speed value of 10 (on a scale of 0-127) equates to an actual speed of 50mm/s. While this is inaccurate (the actual speed is somewhat less and seems to vary based on the input value, but I'll leave that aside for now), I have tried using these values with the mathematical formulae listed HERE (a simpler version of the same can be found HERE), but to no avail (the problem being that the robot thinks it's rotated 360 degrees immediately and tries to stop, even if I program it to wait after it moves for the first time).

I have since tried a simpler code, making the robot move forward and back at one second intervals while adding its +ve and -ve velocities to a counter, yet the robot never reaches "0" (i.e. it moves forward and then back to its starting position); it just goes forward and back continuously.

I have looked at the inbuilt functions of the Elisa-3 library, but they are useless. The "computeAngle" function is supposed to the robot's orientation and position, yet neither it nor the initAccelerometer function work. (In fact, computeAngle computes its angle in the z axis instead.)

Which brings me back to my question: is there a better way to code an odometer from scratch? Also, are functions that set the speed of a robot universal (i.e. could I use a different library's "setSpeed" function with the Elisa-3)?

P.S. The wheels of the robot aren't identical: I need to set the speed of the right wheel to 9/10ths the speed of the left for it to move in a straight line. While this is an easy adjustment to make (or outright ignore) when it comes to calculations, I felt it was worth mentioning nevertheless.

Thank you in advance.
Nederlands / Re: Wat is een goede alternati...
Last post by tweepuntnul - Today at 11:59 am
- er is naast de datalijn geen clock lijn, dus de ontvanger moet synchroniseren op het startbit dat binnenkomt en daarna op gezette tijden het signaal samplen om te kijken of het een 0 of 1 is. En die dan verzamelen tot een byte.

- er is een kloklijn waarmee zender en ontvanger "in sync" gehouden worden. (bv I2C en SPI hebben dit)

Hi, I bought this motor:

And want to test it out with this library:

And this tutorial:

If I turn it around I only get


In my Serial Monitor. Also it does not matter if I turn clockwise or counter-clockwise.

It should be this:

What should I do to make it count when I am turning it?


Code: [Select]
/* Encoder Library - Basic Example
 * This example code is in the public domain.

#include <Encoder.h>

// Change these two numbers to the pins connected to your encoder.
//   Best Performance: both pins have interrupt capability
//   Good Performance: only the first pin has interrupt capability
//   Low Performance:  neither pin has interrupt capability
Encoder myEnc(5, 6);
//   avoid using pins with LEDs attached

void setup() {
  Serial.println("Basic Encoder Test:");

long oldPosition  = -999;

void loop() {
  long newPosition =;
  if (newPosition != oldPosition) {
    oldPosition = newPosition;
Pages: 1 2 [3] 4 5 ... 10