Show Posts
Pages: [1] 2 3
1  Using Arduino / Motors, Mechanics, and Power / Re: ESC 30A control with USB Host shield on: June 15, 2014, 11:03:36 am
It is bleeping, but i have to deconnected the Accu and then connect the Accu to make the motor running. It is now running for about 2 seconds, after the 2 seconds the motor will stop again!
2  Using Arduino / Motors, Mechanics, and Power / Re: ESC 30A control with USB Host shield on: June 15, 2014, 10:55:16 am
Code:
// Controlling a servo position using a potentiometer (variable resistor)
// by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>

#include <Servo.h>
 
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
}
 
void loop()
{
  val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023)
  val = map(val, 0, 1023, 0, 179);     // scale it to use it with thb e servo (value between 0 and 180)
  myservo.write(val);                  // sets the servo position according to the scaled value
  delay(15);                           // waits for the servo to get there
}

still not working
3  Using Arduino / Motors, Mechanics, and Power / Re: ESC 30A control with USB Host shield on: June 15, 2014, 10:07:55 am
(ARDUINO UNO) I'm using a ps3 library because i am making a rc vehicle controlled by a ps3 controller. I have connected a 2200mAh-35c-7,4v lipo to the esc using xt60.

4  Using Arduino / Motors, Mechanics, and Power / ESC 30A control with USB Host shield on: June 15, 2014, 09:42:15 am
HI, I'm having a problem with my project. I want to control a Hobbyking Brushless motor, with a USB Host Shield.

This is my current code

Quote
/*
 Example sketch for the PS3 Bluetooth library - developed by Kristian Lauszus
 For more information visit my blog: http://blog.tkjelectronics.dk/ or
 send me an e-mail:  kristianl@tkjelectronics.com
 */

#include <PS3BT.h>
#include <Servo.h>
#include <usbhub.h>
// Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude
#include <spi4teensy3.h>
#endif

Servo myservo;  // create servo object to control a servo

USB Usb;
//USBHub Hub1(&Usb); // Some dongles have a hub inside

BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
/* You can create the instance of the class in two ways */
PS3BT PS3(&Btd); // This will just create the instance
//PS3BT PS3(&Btd, 0x00, 0x15, 0x83, 0x3D, 0x0A, 0x57); // This will also store the bluetooth address - this can be obtained from the dongle when running the sketch

boolean printTemperature;
boolean printAngle;

void setup() {
  Serial.begin(115200);
  while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
  if (Usb.Init() == -1) {
    Serial.print(F("\r\nOSC did not start"));
    while (1); //halt
  }
  Serial.print(F("\r\nPS3 Bluetooth Library Started"));
  { 
  myservo.attach(5);  // attaches the servo on pin 9 to the servo object

}
void loop() {
  Usb.Task();

  if (PS3.PS3Connected || PS3.PS3NavigationConnected) {
    if (PS3.getAnalogHat(LeftHatX) > 137 || PS3.getAnalogHat(LeftHatX) < 117 || PS3.getAnalogHat(LeftHatY) > 137 || PS3.getAnalogHat(LeftHatY) < 117 || PS3.getAnalogHat(RightHatX) > 137 || PS3.getAnalogHat(RightHatX) < 117 || PS3.getAnalogHat(RightHatY) > 137 || PS3.getAnalogHat(RightHatY) < 117) {
      Serial.print(F("\r\nLeftHatX: "));
      Serial.print(PS3.getAnalogHat(LeftHatX));
      Serial.print(F("\tLeftHatY: "));
      Serial.print(PS3.getAnalogHat(LeftHatY));
      if (PS3.PS3Connected) { // The Navigation controller only have one joystick
        Serial.print(F("\tRightHatX: "));
        Serial.print(PS3.getAnalogHat(RightHatX));
        Serial.print(F("\tRightHatY: "));
        Serial.print(PS3.getAnalogHat(RightHatY));
      }
    }
  
  { 
    myservo.write(map(PS3.getAnalogHat(RightHatY), 0, 255, 0, 100));
    delay(15);
  }
}
}


My motor isn't reacting at all! Can somebody help me and tell my what i am doing wrong?

Caryl Stuffertz
5  Using Arduino / Programming Questions / Re: expected unqualified-id before 'if' on: June 09, 2013, 02:39:25 pm
Thank you for the code, but it still doesn't work! It says:
In function 'void loop()':
error: 'getTiltPosition' was not declared in this scope

this is the code:
Code:
int tilt_s1 = 2;
int tilt_s2 = 3;
int E1 = 4;   
int M1 = 5;
int E2 = 7;                         
int M2 = 6; 

void setup()
{
   pinMode(M1, OUTPUT);   
   pinMode(M2, OUTPUT);
   pinMode(tilt_s1, INPUT);
   pinMode(tilt_s2, INPUT);
   Serial.begin(9600);
}
void loop(){
  int pos = getTiltPos();
  Serial.println(pos);
  delay(200);
  if (pos == 3)
  {
  for(int value = 0 ; value <= 200; value+=5)
  {
    digitalWrite(M1, HIGH); 
    digitalWrite(M2, HIGH);
    analogWrite(E2, 200);   
    analogWrite(E1, 200);   //PLL Speed Control
    delay(30);
  }
 
 }
 else{
  for(int value = 0 ; value <= 100; value+=5)
  {
    digitalWrite(M1, LOW); 
    digitalWrite(M2, LOW);   
    analogWrite(E1, 100);
    analogWrite(E2, 100);   //PLL Speed Control
    delay(30);
  } 

 }
 
}
6  Using Arduino / Programming Questions / Re: expected unqualified-id before 'if' on: June 09, 2013, 01:53:59 pm
So

 
Quote
//Arduino PLL Speed Control:
int E1 = 4;   
int M1 = 5; 
int E2 = 7;                         
int M2 = 6;
int tilt_s1 = 2;
int tilt_s2 = 3;

void setup()
{
 pinMode(M1, OUTPUT);
 pinMode(M2, OUTPUT);
 pinMode(tilt_s1, INPUT);
 pinMode(tilt_s2, INPUT);
 Serial.begin(9600);   
}
 
void loop(){
  int position = getTiltPosition();
  Serial.println(position);
  delay(200);
}

int getTiltPosition(){
  int s1 = digitalRead(tilt_s1);
  int s2 = digitalRead(tilt_s2);
  return (s1 << 1) | s2;
 
}
 void engine()
{
  if (position == 3)
  {
  int value
  for(value = 0 ; value <= 1; value+=5)
  {
    digitalWrite(M1, HIGH); 
    digitalWrite(M2, HIGH);
    analogWrite(E2, 1);   
    analogWrite(E1, 1);   //PLL Speed Control
    delay(30);
  }
 
 } 
 
     
{
else
  int value
  for(value = 0 ; value <= 1; value+=5)
  {
    digitalWrite(M1, LOW); 
    digitalWrite(M2, LOW);   
    analogWrite(E1, 1);
    analogWrite(E2, 1);   //PLL Speed Control
    delay(30);
  } 


 
 
7  Using Arduino / Programming Questions / Re: expected unqualified-id before 'if' on: June 09, 2013, 01:44:32 pm
Quote
You can't turn an if statement into a function, you can only nest it within the function.

the statement is = if (position == 3)
8  Using Arduino / Programming Questions / Re: expected unqualified-id before 'if' on: June 09, 2013, 01:39:26 pm
Because i don't understand how you nest a statement into a code!
9  Using Arduino / Programming Questions / Re: expected unqualified-id before 'if' on: June 09, 2013, 01:32:56 pm
but if i turn
Code:
if (position == 3)
in to
Code:
int if (position == 3)

it stills shows the error of expected unqualified-id before if
10  Using Arduino / Programming Questions / Re: expected unqualified-id before 'if' on: June 09, 2013, 01:28:51 pm
Can you give me an example of how i am supposed to do it because i don't have much time left!
11  Using Arduino / Programming Questions / Re: expected unqualified-id before 'if' on: June 09, 2013, 01:25:47 pm
Thank You!

But now its shows another error!
Code:
//Arduino PLL Speed Control:
int E1 = 4;   
int M1 = 5; 
int E2 = 7;                         
int M2 = 6;
int tilt_s1 = 2;
int tilt_s2 = 3;

void setup()
{
 pinMode(M1, OUTPUT);
 pinMode(M2, OUTPUT);
 pinMode(tilt_s1, INPUT);
 pinMode(tilt_s2, INPUT);
 Serial.begin(9600);   
}
 
void loop(){
  int position = getTiltPosition();
  Serial.println(position);
  delay(200);
 

int getTiltPosition(){
  int s1 = digitalRead(tilt_s1);
  int s2 = digitalRead(tilt_s2);
  return (s1 << 1) | s2;
 
}
if (position == 3)
  {
  int value
  for(value = 0 ; value <= 1; value+=5)
  {
    digitalWrite(M1, HIGH); 
    digitalWrite(M2, HIGH);
    analogWrite(E2, 1);   
    analogWrite(E1, 1);   //PLL Speed Control
    delay(30);
  }
 
 } 
 
     
{
else
  int value
  for(value = 0 ; value <= 1; value+=5)
  {
    digitalWrite(M1, LOW); 
    digitalWrite(M2, LOW);   
    analogWrite(E1, 1);
    analogWrite(E2, 1);   //PLL Speed Control
    delay(30);
  } 

 }
 
 

ino: In function 'void loop()':
error: 'getTiltPosition' was not declared in this scope
error: a function-definition is not allowed here before '{' token
error: expected initializer before 'for'
error: 'value' was not declared in this scope
error: expected `;' before ')' token
error: 'else' without a previous 'if'
error: expected initializer before 'for'
error: 'value' was not declared in this scope
error: expected `;' before ')' token
12  Using Arduino / Programming Questions / Re: expected unqualified-id before 'if' on: June 09, 2013, 01:16:40 pm
sorry I am a newbie. So how do you put it in a function (i'm dutch and 12 years so sorry for my english)
13  Using Arduino / Programming Questions / Re: expected unqualified-id before 'if' on: June 09, 2013, 01:13:06 pm
how do you make the if statement in a function?
All code to be executed needs to be in a function.

your if statement is not in a function.

Also, you should be using == rather than = in the if.
14  Using Arduino / Programming Questions / Re: expected unqualified-id before 'if' on: June 09, 2013, 01:11:49 pm
it still doesn't work

error: expected unqualified-id before 'if'
15  Using Arduino / Programming Questions / expected unqualified-id before 'if' on: June 09, 2013, 01:09:27 pm
the code doesn't work!

Code:
//Arduino PLL Speed Control:
int E1 = 4;   
int M1 = 5; 
int E2 = 7;                         
int M2 = 6;
int tilt_s1 = 2;
int tilt_s2 = 3;

void setup()
{
 pinMode(M1, OUTPUT);
 pinMode(M2, OUTPUT);
 pinMode(tilt_s1, INPUT);
 pinMode(tilt_s2, INPUT);
 Serial.begin(9600);   
}
 
void loop(){
  int position = getTiltPosition();
  Serial.println(position);
  delay(200);


int getTiltPosition(){
  int s1 = digitalRead(tilt_s1);
  int s2 = digitalRead(tilt_s2);
  return (s1 << 1) | s2;
}

if (position = 3)
  {
  int value
  for(value = 0 ; value <= 1; value+=5)
  {
    digitalWrite(M1, HIGH); 
    digitalWrite(M2, HIGH);
    analogWrite(E2, 1);   
    analogWrite(E1, 1);   //PLL Speed Control
    delay(30);
  }
 
  }   
{
else
  int value
  for(value = 0 ; value <= 1; value+=5)
  {
    digitalWrite(M1, LOW); 
    digitalWrite(M2, LOW);   
    analogWrite(E1, 1);
    analogWrite(E2, 1);   //PLL Speed Control
    delay(30);
  } 

}
Pages: [1] 2 3