Show Posts
Pages: 1 ... 88 89 [90] 91 92 ... 225
1336  Using Arduino / Programming Questions / Re: PLS HELP!? on: October 17, 2013, 09:33:15 am
Paul said you have wonky braces.... count them, as below:


Code:
// Connect green LED to pin 10
// Connect yellow LED to pin 11
// Connect red LED to pin 12
// Connect Piezo to pin A0

void setup()  {
  // declare pin 10,11,12 to be outputs:
  // declare pin A0 to be inputs:
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(A0, INPUT);
}

void loop(){{    //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< yoou have open open
   digitalWrite(12, HIGH); // Turns LED on pin 12 on
 delay; } // LED on pin 12 remains on for limited seconds  //<<<<<<<<<<<<<<<<<here's a close, so one open left to close
  
  pinMode(A0, INPUT); // if activated rest of the code continue
  
   digitalWrite(12, LOW); //  Turns LED on pin 12 off
 delay(2000);} // LED on pin 12 turns off 2 seconds    //<<<<<<<<<<<< here's a close, so the opens are matched
  
   digitalWrite(11, HIGH); // Turns LED on pin 11 on //<<<<<<<<<< so from here on, it's outside the loop() function
 delay(2000); // LED on pin 11 remains on for 2 seconds
   digitalWrite(11, LOW); //  Turns LED on pin 11 off

So have a think about that.... clue: the closing } of loop() goes right at the end of whatever should be in the loop. And you have an unnecessary {} as Paul pointed out.....
1337  Using Arduino / Project Guidance / Re: Driving Linak actuator and 4 Electric braking Castors with a Joystick on: October 17, 2013, 05:00:09 am
I'm from Horsham too.... in Sussex.
1338  Using Arduino / Project Guidance / Re: Driving Linak actuator and 4 Electric braking Castors with a Joystick on: October 17, 2013, 02:57:48 am
I had a quick Google... at work so didn't spend too long, and looked at some photos.... it seems to me that the joustick might merely be 4 switches, one in each direction, and simply therefore an on/off on each direction. I may be wrong: should be easy to fathom out with a meter across the terminals?

If it IS simply 4x switches, then it's a much simpler proposition I reckon.
1339  Using Arduino / Project Guidance / Re: Driving Linak actuator and 4 Electric braking Castors with a Joystick on: October 17, 2013, 01:26:03 am
I'd suggest the first thing to do is to get the joystick working- most are simply 2 potentiomenters are right angles.

This tutorial explains how to read a pot.... check the data sheet for your joystick, but it's likely that you just need to double up the code in the tutorial sketch, using a different pin for each axis of course smiley and using variable names like sensorValueX and sensorValueY.

Then you can at least see that you can read the joystick on both axes.
1340  Using Arduino / Project Guidance / Re: Driving Linak actuator and 4 Electric braking Castors with a Joystick on: October 15, 2013, 11:19:23 pm
It's not clear (to me, anyway  smiley-cool) if you're using the joystick itself as the hand-control or merely the switches....might be worth clearing that up to get suggestions.
1341  Using Arduino / Programming Questions / Re: analogRead not working the way I thought. on: October 15, 2013, 10:10:20 am
Check out the description of the if statement and see the difference between = and ==

1342  Using Arduino / Programming Questions / Re: initiating IF statement with a keystroke to control an LED on: October 14, 2013, 10:17:08 pm
Here's (an extract from) some code I use to drive motors based on keypresses....

Code:
char incomingByte;   // for incoming serial data

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

void loop()
{
   if (Serial.available() > 0) {
                // read the incoming byte:
                incomingByte = Serial.read();

                // say what you got:
                Serial.print("I received: ");      
                Serial.println(incomingByte);    // just to prove it's being received
        }  
        
        
         if (incomingByte == 'S')
        {
          //  do stuff;
        }
}

  

I you decide you need other actions on other keys, then just add else ifs:

Code:
else if (incomingByte == 'X')
        {
          // do other stuff
        }
1343  Using Arduino / Project Guidance / Re: Robot Expansion on: October 14, 2013, 12:36:03 pm
How about Passive Infra Red PIR so that it leaps into action when someone comes close.
1344  Using Arduino / Programming Questions / Re: PWM question on: October 13, 2013, 11:10:56 pm
Quote
So what is the difference between the two methods?

Way I understand it, is that in the end the two ways are the same: the servo way just takes the drudge out of us having to convert the degrees we want into the pulse characteristics. The servo way does that under the hood, and sends a pulse of the correct characteristics, which we could of course do longhand.
1345  Using Arduino / Programming Questions / Re: Arduino help for a novice :( on: October 13, 2013, 10:58:23 pm
Word of caution: I've never used a continuous servo, but from what I've read here the 90 degree value for stop is not necessarily precise. You may find yours varies a degree or two either side: maybe yours will be stopped at 88... time will tell.
1346  Using Arduino / Motors, Mechanics, and Power / Re: Stepper motor power supply on: October 13, 2013, 10:56:00 pm
Well thank you everyone for the help.  I will post again with my results once I get it running at tested.  Off to find a suitable power supply!!!!

I don't know what your budget is, and you've said you don't want to get a new non-298 driver, and also that this is an academic exercise right now, but your academic learning experience will be enhanced by getting a new driver while you get a power supply.....
1347  Using Arduino / Motors, Mechanics, and Power / Re: Stepper motor power supply on: October 13, 2013, 10:39:57 pm
Quote
If you get a 5 Volt, 4 amp power supply, you can at least try an experiment without using resistors. This is because at high currents the L298N chip will drop 2 volts or more, leaving 3 volts or less for the motor.

In fact it drops 2v (ok, 1.8v) from the word go, at no load, rising to 5v drop at 2A iirc.
1348  Community / Exhibition / Gallery / Re: Arduino 6502 emulator + BASIC interpreter on: October 13, 2013, 10:33:51 pm
Brilliant...

6502.... Apple ][.... that takes the clock back a bit!
1349  Using Arduino / Programming Questions / Re: Arduino help for a novice :( on: October 13, 2013, 10:27:54 pm
My understanding of a continuous rotation servo is that when you send it the "position" value (as you would have for a normal servo), that value is direction and position together. Normal servos go from 0 degrees to 180, with 90 in the middle. For continuous rotation, 90 means stop, 0 is full speed one way and 180 is full speed the other.

So it's really no different from the normal servo code in the servo knob tutorial: you control the continuous servo's speed and direction at the same time, just as if it was a normal servo's position.

Each axis of a joystick is just a potentiometer: so with an XY joystick you could control both servos from one joystick. Of course, you could use two if you want to, but you would only use half of each joystick: only one of the two axes.

Either way, you just duplicate the necessary parts of that linked code, changing and servo name and pin number where appropriate, for example:

Code:
Servo myservo;  // create servo object to control a servo
 
int potpin = 0;  // analog pin used to connect the potentiometer
int val;    // variable to read the value from the analog pin
 
void setup()
{
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

might become:

Code:
Servo myservo1;  // create servo object to control a servo
Servo myservo2;
 
int potpin1 = 0;  // analog pin used to connect the potentiometer
int potpin2 = 1;
int val1;    // variable to read the value from the analog pin
int val2;
 
void setup()
{
  myservo1.attach(9);  // attaches the servo on pin 9 to the servo object
myservo2.attach(10)  
}

// etc etc

EDIT.... which is more or less what you posted meantime
1350  Using Arduino / Project Guidance / Re: sensor for line following which is easy to program on: October 13, 2013, 02:30:31 pm
Have a look at Pololu
Pages: 1 ... 88 89 [90] 91 92 ... 225