Show Posts
Pages: 1 ... 70 71 [72] 73 74 ... 251
1066  Using Arduino / Programming Questions / Re: Bit stuck on bit manipulations ? on: February 28, 2014, 04:26:51 pm
Yes, your right. It should have been. byte B1 = B00101100 & 0x3F; // 0x3F = B00111111;
Why is Octal even used anymore, it should just be binary, decimal and hex.
1067  Using Arduino / Programming Questions / Re: Bit stuck on bit manipulations ? on: February 28, 2014, 03:48:12 pm
Ok so get a reading of the values before and after you change them, then  compare them to what you should be getting.

You might need to typecase the read value as ints then add them.
1068  Using Arduino / Programming Questions / Re: Bit stuck on bit manipulations ? on: February 28, 2014, 03:16:58 pm
Quote
Byte 1: 00101100 //use last 6 bits
Byte 2: 11001101  //use all 8 bits
Byte 3: 01011100 //use all 8 bits
Byte 4: 11100000 //use first 3 bits

byte B1 = 00101100 & 0x3F; // 0x3F = 00111111;
byte B4 = 11100000 & 0xE0; // 0xE0 = 11100000;
Bytes B2 and B3 can stay the same.
1069  Using Arduino / Programming Questions / Re: Help with Science Fair Project Code. on: February 28, 2014, 01:41:20 am
I just tested the code you provided above, and it works like the way it is written. I didn't change anything,
Try this, add Serial.println(Direction); right after you read it, I want to know if you get back what you sent in.
1070  Using Arduino / Programming Questions / Re: Help with Science Fair Project Code. on: February 28, 2014, 12:57:33 am
Direction is a byte, change it to char and see if it makes a difference. I see you have delays in there, it's ok for testing but the final code should not have delays in it.
1071  Using Arduino / Programming Questions / Re: Problem debouncing multiple buttons on: February 27, 2014, 11:43:28 pm
Post your full code in code tags.
1072  Using Arduino / Programming Questions / Re: Help with Science Fair Project Code. on: February 27, 2014, 10:19:26 pm
So wait, when the robot does not receive a signal from the app, it is supposed to rely on the sensor? If that is the case, then you had it correct.

But this still doesn't seem correct. With this part here, you won't be able to get any data unless the bluetooth app is actually sending something. However, like I said, if you want to test it with the serial monitor then you need change BTSerial to just Serial.
 
Quote
if (BTSerial.available() > 0) // Check and see if there is serial input
{ Direction = Serial.read(); // If there is input set the Direction variable to that value.
1073  Using Arduino / Project Guidance / Re: Robot arm problems with joysticks and base on: February 27, 2014, 10:12:28 pm
It springs back, ok then you will need a button to hold the position of where you want the servo to stay.
You can use the joy stick like normal, and you can press and hold a button to move the servo then release where you want it. However with this method you need to tell the code to disregard the joystick reading when you are not moving it, otherwise it will move the servo when you don't want it to.
1074  Using Arduino / Programming Questions / Re: Problem debouncing multiple buttons on: February 27, 2014, 10:04:35 pm
Can you please fix you post and put your code inside code tags. Its the # symbol above the smiley faces.
1075  Using Arduino / Programming Questions / Re: I need some help with my program. on: February 27, 2014, 04:54:42 pm
Ok, then you can use the debounce example and instead of turning on a led, you can increment a counter. That counter will turn on the output that you want.
1076  Using Arduino / Programming Questions / Re: I need some help with my program. on: February 27, 2014, 04:27:03 pm
Do you want to change the outputs per click or see how many times the button was clicked within a few seconds then turn on the corresponding output?
1077  Using Arduino / Programming Questions / Re: Problem debouncing multiple buttons on: February 27, 2014, 02:55:32 pm
Those delay even though they are small, they will slow the code down incorrectly. Look into the Blink without Delay sketch to replace those delays.

As for the debounce code.
Code:
/*
 Debounce
 This example code is in the public domain.
 http://www.arduino.cc/en/Tutorial/Debounce
 */

// constants won't change. They're used here to
// set pin numbers:
const byte MAX_PINS = 4; // how many buttons to look for
const byte buttonPin[MAX_PINS] = {A0,A1,A2,A3}; // Number of buttons
const byte ledPins[MAX_PINS] = {13,12,11,10}; // the number of the LEDs
const long debounceDelay = 50; // the debounce time; increase if the output flickers

byte counter=0;
boolean currentState[MAX_PINS]; // Initial storage for the state of the button
boolean buttonState[MAX_PINS]; // the current state from the input pin
boolean lastButtonState[MAX_PINS] = {LOW,LOW,LOW,LOW}; // the previous state from the input pin
long lastDebounceTime[MAX_PINS] = {0,0,0,0}; // the last time the output pin was toggled

void setup()
{
  for(byte i = 0; i <= MAX_PINS; i++)
  {
    pinMode(buttonPin[i], INPUT); //set button states
    pinMode(ledPins[i], OUTPUT); // set LED states
  }
}

void loop()
{
  counter < MAX_PINS? counter++ : counter = 0;

  currentState[counter] = digitalRead(buttonPin[counter]);// look at button input and record it.
 
  if (currentState[counter] != lastButtonState[counter]) // Check to see if the state has changed, indicating button is not held
    lastDebounceTime[counter] = millis();

  if ((millis() - lastDebounceTime[counter]) > debounceDelay) // check debounce time
    buttonState[counter] = currentState[counter];
 
  digitalWrite(ledPins[counter], buttonState[counter]); // light specific LED
 
  lastButtonState[counter] = currentState[counter]; // save current state to last state
  //Serial.print("counter: ");
  //Serial.print(counter);
  //Serial.println();

}
This can be made into a function like how you have yours, then all you need to return is "buttonState[counter]"
1078  Using Arduino / Project Guidance / Re: 2.4" TouchScreen Shield in Arduinouno on: February 27, 2014, 11:43:41 am
What library does it use and see what available functions it has already. I'm sure it has some example sketches that came with it, like a demo of its features.
1079  Using Arduino / Programming Questions / Re: Help with Science Fair Project Code. on: February 27, 2014, 03:11:26 am
You are aware that the only time you get measurement is when your not sending anything over Bluetooth. Make the "ping" section a function that you can call when you need it, instead of how you have it now.

Also if your currently using the serial monitor to test the code, then why are you checking if the Bluetooth is sending something when your reading from the serial monitor?
Quote
if (BTSerial.available() > 0) // Check and see if there is serial input
{ Direction = Serial.read(); // If there is input set the Direction variable to that value.
{ <= unneeded bracket, get rid of it and its closing counterpart.
1080  Using Arduino / Project Guidance / Re: Control DC motors using Arduino on: February 27, 2014, 01:03:27 am
Quote
I need help to control the DC speed motors speeds

Easy enough, the analogWrite function is what you need to use. What are you going to use as a motor controller? Make sure you take into consideration the power to weight ratio. The sum of the combined weights must be less than what the motors can provide, otherwise it will not get off the ground.

Quote
make my quadcopter hover at a certain position above the earth.
This will require a GPS module.
Pages: 1 ... 70 71 [72] 73 74 ... 251