Show Posts
Pages: [1] 2 3
1  Using Arduino / Project Guidance / Re: Arduino Ethernet and Google Analytics!? on: January 09, 2014, 12:51:32 pm
Hi, did you ever get this working?

I'm looking to do a similar thing.

Cheers.

Phil
2  Using Arduino / Programming Questions / Re: Inconsistent Pot reading on: July 24, 2012, 11:43:15 am
Thanks, there is very little else going on. I have a small shield that I made that has 3 transistors for controlling LEDs but even when they are not receiving power I get the issue.

The shifting bits and averaging works great for now.

Thanks,

Phil
3  Using Arduino / Programming Questions / Re: Inconsistent Pot reading on: July 24, 2012, 11:31:08 am
10k pot
4  Using Arduino / Programming Questions / Re: Inconsistent Pot reading on: July 24, 2012, 10:52:28 am
That did work better but it was still a little noisey, I combined this with some averaging and it worked great.

Thanks.

Phil
5  Using Arduino / Programming Questions / Inconsistent Pot reading on: July 24, 2012, 03:40:36 am
Hi, I am having trouble getting a steady value from my pot.

I read that it can often help to average the value so I added a little loop.

Even with this code, my values are fluctuating.

potVal displays from 0 - 1023 but often the value is not steady.

I have tried other pots and get similar issues.

Any ideas?

Thanks.

Phil


Code:
void setup() {
    Serial.begin(9600);           



}

void loop() {
 
 
 
  int potAvg=0;
  int potVal=0;

for (int i=0; i< 25 ; i++) potAvg += analogRead(2); // take an average
potVal = potAvg / 25 ;

Serial.println (potVal);

delay (100);
}
6  Using Arduino / Networking, Protocols, and Devices / Re: Serial Read Issue (again) on: May 17, 2012, 02:11:50 am
wooop wooop.

I think I have figured it out.

I tried using "serialport x" to send the text to my arduino and it seems to be working perfectly !!!!

Thanks for all your help so far.

Phil
7  Using Arduino / Networking, Protocols, and Devices / Re: Serial Read Issue (again) on: May 16, 2012, 10:30:44 pm
Thanks Paul, I am not too worried about my bad coding and inefficient use of variables (I will go back and fix all those in time).

What I really need help with is the serial read issue that only works effectively when serial monitor is open.

I am wondering what a next logical step would be in debugging my issue.

If we think it could be the arduino-serial app that I'm using to send the data, are there other tools I could use to test my setup?

I usually use OSX but have access to Windows Vista too.

Any idea of other tools that could send a string to a serial port?

Or, any other advice on this issue?

Thanks.

Phil

8  Using Arduino / Networking, Protocols, and Devices / Re: Serial Read Issue (again) on: May 16, 2012, 12:51:57 am
Wow, thanks again for your input (you must be able to tell I'm a novice).

I'll reply to thew best of my knowledge....
Quote
Why? inData is perfectly acceptable as input to atol(), as long as it contains only numeric data (which making a pointer to point does nothing to ensure).
For some reason, I couldn't get atol() to work with my inData variable.

Quote
Pretty optimistic, aren't you?
My video is close to reaching 1000,000 views on YouTube, this counter is part of the celebration although it's looking like this serial problem might mean the project doesn't get done in time.

Quote
This tells me that AppleScript is not configuring the serial port correctly.

The big issue is the serial monitor problem. I am using a command line tool to send that data to the serial port, the tool is specifically written for Arduino. Information on that tool is here.

http://todbot.com/blog/2006/12/06/arduino-serial-c-code-to-talk-to-arduino/

I have hacked my script apart to just the basics as that might help discover the issue.

Basically all it does is:

Wait for something from the serial port.
If it is "<" then collect all of the following characters.
Once it get ">" stop reading the data.
Print data to the LCD.

Again this script only functions correctly if the serial monitor is open.

One more behavior is that if I open the serial monitor then close it, it often still works. Could it be that the serial monitor is doing some kind of initialization of the serial port?.

Anyway, here is my simplified code.

Code:
#define SOP '<'
#define EOP '>'

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display


bool started = false;
bool ended = false;
int countStrt = 0;

char inData[80];
byte index;
int timeout=0;
int timeoutFlag=0;
long previousCount = 0 ;

void setup()
{
   Serial.begin(57600);
   lcd.init();
   lcd.backlight();
   lcd.clear();


}

void loop()
{
 
 
     
  while(Serial.available() > 0)
  {   
     char inChar = Serial.read();
   
    if(inChar == SOP) //start packet
    {
   

      index = 0;
      inData[index] = '\0';
      started = true;
      ended = false;
    }
    else if(inChar == EOP)
    {
      ended = true;
      break;
    }
    else
    {
      if(index < 20)
      {

        inData[index] = inChar;
        index++;
        inData[index] = '\0';
      }
    }
  }

  // We are here either because all pending serial
  // data has been read OR because an end of
  // packet marker arrived. Which is it?
  if(started && ended)
  {
    // The end of packet marker arrived. Process the packet
    // Serial.println(inData);

     lcd.clear();

    lcd.print(inData);

       started = false;
      ended = false;
      index = 0;
      inData[index] = '\0';

   
}}

I would LOVE to figure this out before my video reaches 1000,000 views !!!

Thanks again.

Phil





9  Using Arduino / Interfacing w/ Software on the Computer / Re: Command line Mac OS X on: May 15, 2012, 11:22:38 pm
I use arduino-serial, its a free app that sends data via the terminal.

http://todbot.com/blog/2006/12/06/arduino-serial-c-code-to-talk-to-arduino/comment-page-8/#comment-81341

10  Using Arduino / Interfacing w/ Software on the Computer / Re: reading serial ports with acc on mac on: May 15, 2012, 11:18:12 pm
Here is another link that may help.

http://blog.makezine.com/2011/04/08/the-awesome-button/
11  Using Arduino / Networking, Protocols, and Devices / Re: Serial Read Issue (again) on: May 14, 2012, 11:45:22 pm
Replying to my own thread here...

It seems to be an issue with incorrect NULL termination of my string.

I'm still trying to fix my code and am not sure what needs to be done exactly but I feel like I'm getting closer.

Again, any tips would be greatly received.

Phil


12  Using Arduino / Networking, Protocols, and Devices / Re: Sending string to LCD from a browser on: May 14, 2012, 11:03:31 pm
I am doing a similar project, my method is to use AppleScript to read data from and API then pass that to the Arduino to display on the LCD.

If you are using OSX then I can help a little, Windows not so much.

Message me if you would like more "Mac based" information on how to get the data from the web to the Arduino.

I have actually hit one major issue which I posted about yesterday in which the serial only seems to work when the Arduino Serial monitor is open.

http://arduino.cc/forum/index.php/topic,105763.0.html

I feel like this is only a minor issue and I am happy to help you with any other info.
13  Using Arduino / Networking, Protocols, and Devices / Serial Read Issue (again) on: May 14, 2012, 12:21:12 am
Hi, I thought I had my project all working but for some reason it is still not 100%.

Basically I have an AppleScript that is sending serial data to the Arduino Uno and the Uno is displaying it on an LCD.

It works great except for the fact that it only works when the Arduino serial monitor is open. At first it was the common problem of the board resetting with each serial read. I fixed this issue by cutting the trace on my Uno.

Currently, if I have my Uno running and the AppleScript sending data every 10 seconds, I will eventually get some corrupt data on my LCD.

As soon as I open the serial monitor and send data from my AppleScript, it works perfectly.

It's driving me nuts.

Any ideas?

Thanks.

Phil
Code:

#define SOP '<'
#define EOP '>'

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display


bool started = false;
bool ended = false;
int countStrt = 0;

char inData[80];
byte index;
int timeout=0;
int timeoutFlag=0;
long previousCount = 0 ;

void setup()
{
  Serial.begin(57600);
  lcd.init();
  lcd.backlight();
  lcd.clear();


}

void loop()
{




  if (timeout == 0 || timeout > 15) {    // test to see if the Arduino is still waiting

    previousCount = 0 ; // reset count
    if (timeoutFlag==0) { // to avoid LCD refresh
      lcd.clear();
      lcd.print("Waiting for App....");
      timeoutFlag =1;
    }


  }
  timeout++;


  while(Serial.available() > 0)
  {


    char inChar = Serial.read();
    if(inChar == SOP) //wait for start packet
    {

      timeoutFlag=0; // reset timeout flag
      timeout = 1; // got some data
      index = 0;
      inData[index] = '\0';
      started = true;
      ended = false;
    }
    else if(inChar == EOP)
    {
      ended = true;
      break;
    }
    else
    {
      if(index < 20)
      {

        inData[index] = inChar;
        index++;
        inData[index] = '\0';
      }
    }
  }

  // We are here either because all pending serial
  // data has been read OR because an end of
  // packet marker arrived. Which is it?
  if(started && ended)
  {
    // The end of packet marker arrived. Process the packet
    // Serial.println(inData);

    char* viewCount = inData; // convert inData to a string

    long newCount = atol(viewCount);


    // Serial.println(newCount);
    if (newCount != previousCount ){
      lcd.clear();
      lcd.print("YouTube Views");

      if (previousCount > 0){

        for (long z=previousCount; z < newCount; z++){ //count up the counter

            String newViewCount = String(z);
          lcd.setCursor(0, 1);
          lcd.print(newViewCount); // display viewCount
          // Serial.println(newViewCount); // display viewCount
          delay (10);
        }
      } // end count up loop

      String newViewCount = String(newCount);

      lcd.setCursor(0, 1);
      lcd.print(viewCount); // display viewCount
      // Serial.println(newViewCount); // display viewCount


        // Reset for the next packet

        previousCount = newCount;
      started = false;
      ended = false;
      index = 0;
      inData[index] = '\0';

    }
  }

  delay (1000);
}




14  Using Arduino / Programming Questions / Re: String to int on: May 02, 2012, 04:15:01 pm
This worked great, thanks,

Phil



Quote
On an arduino, working with string instead of char* is already some overkill, IMO

char* viewCount="1234567";
long number = atol(viewCount);

should already work fine
15  Using Arduino / Programming Questions / String to int on: May 02, 2012, 12:55:24 am
Hi, I found this code snipet for converting a string to an int, it works great with numbers up to 5 digits but after that it fails.

The code below will work but if I change viewCount to "123456" then my int become a negative number.

Any ideas?

Thanks.

Phil


Code:

viewCount="12345";
char this_char[viewCount.length() + 1];
viewCount.toCharArray(this_char, sizeof(this_char));
int newCount = atoi(this_char);
Serial.println(newCount);
Pages: [1] 2 3