Show Posts
Pages: 1 ... 3 4 [5] 6 7 ... 285
61  Using Arduino / Programming Questions / Re: 7-Segment Time Display on: August 13, 2014, 02:41:50 am
Quote
I understand that I can use the Time library

(http://playground.arduino.cc/Code/Time)

to obtain the current time without any external hardware
Stop right there.  You can certainly use the Time library without any external hardware but don't expect the clock to be accurate to more than a few seconds a day and maybe worse.  Start by getting an RTC to keep time for you.
62  Using Arduino / Programming Questions / Re: RPM using hall effect sensor on: August 12, 2014, 04:26:09 pm
Quote
I'm not good programmer
Have you tried using the sensor at all ?
63  Using Arduino / Programming Questions / Re: Arduino does not recognize new line from Matlab fprintf on: August 12, 2014, 03:31:23 pm
Code:
  pinMode(1, OUTPUT);      // sets the digital pin as output
Code:
  pinMode(0, OUTPUT);
Pins 0 and 1 are used by used by hardware Serial so I forsee a problem with using them as outputs
64  Using Arduino / Programming Questions / Re: Arduino as Datalogger- Sketch logs date but not theanalog voltage on SD card! on: August 12, 2014, 02:01:49 pm
To me that makes no sense. 
Without the comma the data in the file would have been formatted differently but it should still have been present.
65  Using Arduino / Programming Questions / Re: Sketch to slow servo speed when using flex sensor on: August 12, 2014, 07:28:17 am
Try this as a start point
Code:
#include <Servo.h>

int flexpin=A0;
int pos;

Servo myServo;
int flexSum;

void setup()
{
  myServo.attach(7);
}

void loop()
{
  flexSum = 0;
  for(int x=0; x < 20; x++)
  {
    flexSum = flexSum + analogRead(flexpin);
    delayMicroseconds(14);
  }
  flexSum = flexSum / 20;

  pos = map(flexSum,870,800,0,90);
  moveServo(pos);
}

void moveServo(int targetPos)
{
  for(int servoPos = 0; servoPos <= targetPos; servoPos++)
  {                     
    myServo.write(servoPos);
    delay(70);
  }

  for(int servoPos = targetPos; servoPos >= 0; servoPos--)
  {                               
    myServo.write(servoPos);
    delay(70);
  }
}
I do not have the hardware to try it on so there may be problems with it.  Note that it only deals with one sensor and servo but that can be extended using arrays, and that I have changed some of your variable names to make more sense.
66  Using Arduino / Programming Questions / Re: Controlling LED's with Trackbar in VS on: August 12, 2014, 07:09:41 am
You have changed the subject slightly by wanting to accept a string rather than a value from the slider but this should get you started.
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=11425&page=1
You need to terminate the incoming string in some way so that the Arduino can recognise that a complete command has been received and act on it.  You could use fixed length messages but using serial there is no guarantee that every character will be received as sent, so a delimited string is a safer way to do it.
67  Using Arduino / Programming Questions / Re: Sketch to slow servo speed when using flex sensor on: August 12, 2014, 04:25:10 am
Quick and dirty method.
Put all the code in the loop() function of the second program in a function in the first program and call it instead of
Code:
myservo.write(pos);
in the first program.  Do you want/need the servos to move at the same time ?  If so then it is a little more complicated but I suggest that you get one working first.

Incidentally, what does this do for you in the first program ?
Code:
if(Serial.available())
{
Serial.println(flexsum);
Serial.println(flexsum1);
delay(100);
}
You have no serial input so the test will always fail.

I assume that you know that the second program does not do exactly what the comments say
Code:
  for(pos = 0; pos <= 85; pos += 1)  // goes from 0 degrees to 180 degrees
68  Using Arduino / Programming Questions / Re: Controlling LED's with Trackbar in VS on: August 12, 2014, 02:40:37 am
As a start just read the serial input to the Arduino and print it on the serial monitor and post the program here so that we can see what you are doing.

Do you have means other than the Arduino to test the output from the slider in VS ?
69  Using Arduino / Programming Questions / Re: Formatting tinygps output on: August 11, 2014, 01:52:44 pm
sprintf() will not work with floats in the Arduino environment.

How about using a simple function to output the float sent to as it as an argument.  In the function check the value of the float and if it is less than 10 then print a space  before it or if the value may exceed 100 then check twice and print the appropriate number of spaces.
70  Using Arduino / Programming Questions / Re: Using external interrupt for controlling push button (as abort function) on: August 11, 2014, 11:25:27 am
One immediately obvious problem is that delay() does not work in an ISR because it uses interrupts which are automatically disabled when the ISR is triggered.  Also all variables changed within an ISR should be declared as volatile.

ISRs should have as little code in as possible and should return as soon as possible.  A common way to achieve this is to set a flag variable inside the ISR and return to the calling program.  Then use the value of the flag variable within loop() to take the necessary actions.
71  Using Arduino / Programming Questions / Re: How can i make a Matrix small or any idears? on: August 11, 2014, 10:16:20 am
Quote
can i make the matrix in this code smaler
Yes.  Use an array of bytes as you have now but use the bits in each byte for the ones and zeroes.  The arrays will take 1/8th of the space.

You can access the value of each bit using bitRead().  See http://arduino.cc/en/Reference/BitRead
72  Using Arduino / Programming Questions / Re: Controlling LED's with Trackbar in VS on: August 11, 2014, 09:33:36 am
Quote
So if I am correct this is sending 7 bytes for 7 steps on the slider.
If you are right then why send 7 bytes ?  All you need to do is to send one value between zero and a maximum that represents the position of the slider.

Code:
trackBar1.Minimum = 0;
trackBar1.Maximum = 7;
Looks like the value will be between zero and 7, ie one of eight values.

It seems to me that you need to do something like
Code:
mySerialPort.Write(Convert.ToByte(trackBar1.Value));
or even just
Code:
mySerialPort.Write(trackBar1.Value);
but please bear in mind that I know nothing about VS so I am guessing
73  Using Arduino / Programming Questions / Re: Weird LCD flicker on: August 11, 2014, 09:21:51 am
Quote
Does this look a little odd to anyone else:
Yes.  Well spotted.
74  Using Arduino / Programming Questions / Re: Button Function on: August 11, 2014, 07:10:21 am
Quote
here full code is
That won't compile either.

Quote
  // nothing happens after setup finishes.
That's because you don't have anything in the loop() function
Code:
void loop()
{
  // put your main code here, to run repeatedly:
}

When you read the button press in setup() all that happens is that the initializingsdcard variable is declared but is not given a value.  As it is not a global variable its value could be anything but that does not matter because it is never checked or used.
Code:
  buttonState = digitalRead(buttonmenu);  // read the state of the pushbutton value:
  if (buttonState == HIGH)
  {     // check if the pushbutton is pressed.
    int initializingsdcard;
  }
75  Using Arduino / Programming Questions / Re: Controlling LED's with Trackbar in VS on: August 11, 2014, 06:53:09 am
Quote
thats correct I am wanting the LED colours to change depending on the position of the slider.
Sending the same character each time the slider moves is not going to work then.  Why not just send a number that represents the position of the slider and use the Arduino to convert this number to an RGB combination ?  How many RGB steps do you want to display ?  This will determine the range of the number to be sent to the Arduino.
Pages: 1 ... 3 4 [5] 6 7 ... 285