Show Posts
Pages: 1 ... 3 4 [5] 6 7 ... 268
61  Using Arduino / Programming Questions / Re: Shift registers - other way around. on: July 07, 2014, 02:28:57 am
Quote
The variable i is not updated by the first line of code
It looks to me as though i is updated by the ternary operator depending on the result of the digitalRead().  What have I missed ?  Try this
Code:
const byte inPin = 8;
byte i;

void setup()
{
  Serial.begin(115200);
  pinMode(inPin, INPUT_PULLUP);
}

void loop()
{
  digitalRead(inPin)==HIGH ? i=1 : i=0;
  Serial.println(i);
  delay(1000);
}
The value of i changes from 1 to 0 when inPin is grounded
62  Using Arduino / Programming Questions / Re: menu using array on: July 07, 2014, 01:40:37 am
I suggest that you post your whole program so that the question can be seen in context.
63  Using Arduino / Programming Questions / Re: Serial Communication Problem!! on: July 07, 2014, 01:38:45 am
I cannot understand your problem from your description, but looking at your code I see that you use serialEvent().  This function will run each time through the loop() function if serial data is available.  In serialEvent() you are reading a single chracter which you add to inputstring
Code:
  char inchar = (char)Serial.read();                               //get the char we just received
  inputstring += inchar;                                           //add it to the inputString
but at the start of loop() you have
Code:
  inputstring = "C\r";
which will replace the data received.
64  Using Arduino / Programming Questions / Re: RGB led lighting project code malfunction on: July 06, 2014, 03:30:20 pm
Code:
digitalWrite;(blue=HIGH);
 Delete the semi-colon after digitalWrite and correct its syntax too.

Similarly look at the pinMode command syntax
65  Using Arduino / Programming Questions / Re: Shift registers - other way around. on: July 06, 2014, 03:26:08 pm
Code:
    digitalRead(button)==HIGH ? i=1 : i=0;
    digitalWrite(dataPin,i);
Why use an intermediate variable when you could just use
Code:
  digitalWrite(dataPin,digitalRead(button));
or it you want to invert the output
Code:
  digitalWrite(dataPin,!digitalRead(button));
66  Using Arduino / Programming Questions / Re: I can't get this sample code to work. on: July 06, 2014, 04:17:04 am
What exactly is wrong ?
Does the IRremote stuff work on its own ?
67  Using Arduino / Programming Questions / Re: Sketch Optimization and Feasibility On An ATtiny on: July 05, 2014, 02:10:36 am
Sorry for the bum steer on the use of const for that variable.
68  Using Arduino / Programming Questions / Re: GPS & nrf24l01+ issues on: July 05, 2014, 02:08:29 am
Auto Format has told you that you have too many right braces, the } character. Each { needs a corresponding } but they must be in the correct place such as the start and end of a function or a code block to be executed when a condition is true, for example.  In the IDE put the cursor to the right of any bracket or brace and the IDE will indicate its corresponding partner, if it exists.

As to
Code:
while(true);
What are you trying to do ?  Will the statement ever be false and allow the program to continue ?
69  Using Arduino / Programming Questions / Re: GPS & nrf24l01+ issues on: July 04, 2014, 04:10:15 pm
Try Auto Formatting your code in the IDE.  You should get a clue as to what is wrong.

Where does the loop() function end in your program ?

Also, is this
Code:
    while(true);
useful ?
70  Using Arduino / Programming Questions / Re: Sketch Optimization and Feasibility On An ATtiny on: July 04, 2014, 12:25:51 pm
Quote
UKHeliBob, would it be better to change
Code:
boolean doorSwitch[3];
to
Code:
int doorSwitch[3];
to make it more clear that I'm actually checking for HIGH/LOW rather than true/false?
Code:
const byte doorSwitch[3];
would be better.  const because the values will never change and byte because it takes less space.
71  Using Arduino / Programming Questions / Re: Arduino Autonomous GPS Navigation on: July 04, 2014, 10:38:34 am
Are you sure that the GPS is getting a lock ?
72  Using Arduino / Programming Questions / Re: Just can't quite get the code right on: July 04, 2014, 04:43:44 am
Quote
I just need to figure a better delay instead of using delay()
All Together Now "BlinkWithoutDelay"
73  Using Arduino / Programming Questions / Re: Sketch Optimization and Feasibility On An ATtiny on: July 04, 2014, 01:29:46 am
Quote
I didn't fully understand what you were saying about booleans. Do you mean to be careful with checking a boolean for its intended value? As in, make sure to only check if true/false booleans are true or false, not HIGH or LOW?
Checking that booleans are true/false is what I meant.  Currently you have
Code:
boolean doorSwitch[3];
Code:
 if (doorSwitch[0] == HIGH || doorSwitch[1] == HIGH)
This works but is not as clear as it might be.
74  Using Arduino / Programming Questions / Re: elapsedMillis help on: July 03, 2014, 10:30:07 am
Code:
if( digitalRead(switchPin)==HIGH)while(digitalRead(switchPin)==LOW);
You check to see whether the switch pin is HIGH and if it is, enter a loop that is only executed if it is LOW.  Have I read that right ?

Code:
if( digitalRead(switchPin)==HIGH)
{
while(digitalRead(switchPin)==LOW);
}
75  Using Arduino / Programming Questions / Re: Breaking down a programme. on: July 03, 2014, 10:15:40 am
Quote
I have noticed that when a function calls another function , the calling function has to be located after the called one for the compiler to find the reference.
Not if you use the Arduino IDE, because it creates the function prototypes behind the scenes and puts them near the start of the program for you.
Pages: 1 ... 3 4 [5] 6 7 ... 268