Show Posts
Pages: 1 ... 90 91 [92] 93 94 ... 285
1366  Using Arduino / Programming Questions / Re: Servo rotation help on: February 10, 2014, 02:18:17 am
In previous code you were testing the pos variable after for loops but it was never the value that you expected because of the way that the for loop end condition was constructed.  That is now fixed but your test for the initial value of pos is flawed.

pos is initially set to zero, so testing to see whether it is 10 or 100 will never be true.  Change the initial value of pos to 10 and try again.

How is the RF receiver powered and does it have  common GND with the Arduino ?  If not then there will be no point of reference for the Arduino to measure HIGH and LOW.
1367  Using Arduino / Programming Questions / Re: Help coding two sensors triggering LEDS on: February 09, 2014, 05:41:17 pm
when I leave my hands for longer period in front of the sensors the LEDs switch on suddenly again
If you look back at reply #1 you will see that I suggested actions should be taken when a sensor goes HIGH, ie changes from LOW to HIGH.  Your current code takes actions when a sensor is HIGH so if you leave your hand in place it will see the HIGH signal again and take the actions again. 

What you need to do when a sensor is seen to be HIGH is to check that its previous state was LOW.  To do this you need to remember the state of the sensor the last time you read it.  This process is known as state change detection and there is an example of it in the IDE.

Nothing to do with this problem, but you can drastically reduce the complexity of your ON/OFF functions by using an array and passing parameters to a single function.
1368  Using Arduino / Programming Questions / Re: LCD Scroll Text on: February 09, 2014, 12:25:34 pm
Roll your own scroll example.
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

const byte i2cAddress = 0x27;
const byte backlightPin= 3;
char * message = "Scroll me";

LiquidCrystal_I2C lcd(i2cAddress);  //NOTE library changed by BB to hard code pin numbers

void setup()
  lcd.begin (16,2);
  lcd.setBacklightPin(backlightPin ,POSITIVE);
  lcd.print("Stay Still");

void loop()
  for (int printStart = 15; printStart >= 0; printStart--)  //scroll on from right
    showLetters(printStart, 0);

  for (int letter = 1; letter <= strlen(message); letter++)  //scroll off to left
    showLetters(0, letter);

void showLetters(int printStart, int startLetter)
  for (int currentLetter = startLetter; currentLetter < strlen(message); currentLetter++)
  lcd.print(" ");
Note that this is written for an I2C LCD so the initialisation will be need to be changed to suit yours, and as currently written the scrolling message cannot be wider than the LCD,  but that could be fixed.
1369  Using Arduino / Programming Questions / Re: Need help parsing serial data stream please. on: February 08, 2014, 05:27:29 pm
Not the same thing at all.
Especially since one is true and one is not.
That was my point.
1370  Using Arduino / Programming Questions / Re: Need help parsing serial data stream please. on: February 08, 2014, 04:13:11 pm
string functions are quite slow.
Do you mean String functions are quite slow or string functions are quite slow ?  Not the same thing at all.
1371  Using Arduino / Programming Questions / Re: Need help parsing serial data stream please. on: February 08, 2014, 02:04:59 pm
Build a string from the incoming characters then when it is complete (you need an end of message indicator) use strtok to split it at the commas then you can split each substring and turn the number strings into numbers using the strtof function if you actually need the numbers, otherwise just display the number substrings.

Note that several of your not integers.
1372  Using Arduino / Programming Questions / Re: check if serial-input contains string on: February 08, 2014, 01:57:28 pm
        if (inputString.substring(0)=="newrfid")
How many characters does inputString.substring(0) return ?
1373  Using Arduino / Programming Questions / Re: why dosent this code (Read integers from serial) work?? on: February 08, 2014, 09:33:26 am
And on the receiver side, i will have something that looks for the "T", and only then tries to parse the digits to integers??
You could do something like that by putting the characters into an array as they are received and then parsing the string. when the termination character is received. This is a good idea, but it will not solve the problem of trying to read from Serial when there is nothing there to read.  At the moment you check that Serial.available() is greater than zero and immediately assume that there are several characters available by using parseInt().  Before reading from Serial you must test to know that at least one character is available.
1374  Using Arduino / Programming Questions / Re: help with want a controlled signal on: February 07, 2014, 02:50:20 pm
#include <sensepin = 0>                                   
#include <sensepinh = 7>///////extra temperature censor attached to car
#include <sensepina = 8>/////connected to engine oil sensor
#include <sensepinb = 9>///connectd to engine  water bottle
#include <sensepinc = 10>///////extra temperature cut out switch attached to car
I read this far into your code then stopped.  What are these lines of code supposed to do ?
1375  Using Arduino / Programming Questions / Re: ENCODER HOW TO ENCREASE THE PRECISION ,? on: February 07, 2014, 02:00:11 pm
void encoder(const int piste_A, const int piste_B)

  attachInterrupt(0,direction_speed, RISING);
What is this function supposed to be doing ?  It is supplied 2 parameters that are never used in the function and attaches an interrupt each time through the loop() function when it only needs to be attached once in setup()

Then, later on, in the middle of the ISR you attach the same interrupt to another routine 20 times

What's that all about ?

Later in the same ISR you attempt to print a variable that is not defined even though Serial.print() does not work in an ISR because interrupts are disabled.
1376  Using Arduino / Programming Questions / Re: Communication between arduinos with sensors on: February 07, 2014, 01:18:25 pm
How are the 2 Arduinos connected at the moment ?

You don't need to pack the data on the sending Arduino beyond adding a "start of message" indicator, a dividing character between each value and an "end of message" indicator at the end of the message.  Most of the work then takes place on the receiving Arduino.  This will be a good place to start in order to build a string on the receiving Arduino that you can then take apart using the strtok() function using the dividing characters that you added before transmission.

Is it a good idea to use the same serial interface for receiving data and writing to the serial output ?
1377  Using Arduino / Programming Questions / Re: Arduino Uno Project - Counter does not begin from 0 on: February 07, 2014, 01:06:27 pm
If you cannot track down the problem and understand it then it may come back to bite you at some time.  Did you try what I suggested in reply #9 ?
1378  Using Arduino / Programming Questions / Re: Communication between arduinos with sensors on: February 07, 2014, 12:32:43 pm
Start by using SoftwareSerial on both Arduinos assuming that the boards do not have 2 or more hardware serial ports.  That will enable you to use the hardware serials on the Arduinos to debug your code.  Connect the 2 Arduinos together using the pins defined in their SoftwareSerial setups.

Now, forget your eventual aim.  Can you send a single, hard code byte from Arduino A to Arduino B, read it and display it ?  When you can do that you are ready to move on.
1379  Using Arduino / Programming Questions / Re: Compile two sketches on: February 07, 2014, 12:26:59 pm
I'm using Cytron's LCD Keypad Shield, so...?
That uses pin 9 for the LCD too so you cannot use that for the servo, but you do need it connected to make the LCD work I would think.

From the Cytron documentation
Pin Function
Analog 0 Button (select, up, right, down and left)
Digital 4 DB4
Digital 5 DB5
Digital 6 DB6
Digital 7 DB7
Digital 8 RS (Data or Signal Display Selection)
Digital 9 Enable
Digital 10 Backlight Control
1380  Using Arduino / Programming Questions / Re: Arduino Uno Project - Counter does not begin from 0 on: February 07, 2014, 12:16:23 pm
I solved the problem by using the variable R and R2 in my code, and now it starts counting from 0
You didn't solve it, you worked around it by adding a fudge factor.
Pages: 1 ... 90 91 [92] 93 94 ... 285