Simple Question and YES i got my Arduino!!!

Hello,

Today i received my arduino by post! I tryed to get it work and it works!!! Directly i tested the arduino and it works! My next step was OFCORSE to get a connection by PERL and the Arduino and had some trouble with the serial connection but i already figured that out and got it all working :slight_smile:

But i have a litle problem and mayby it is a simple solution for you please tell me how i can use a variable pin output :-[

This is the code i have for now:

char incomingByte;
char str1[50];
int count = 0;

void setup () {
  beginSerial (19200);
}


void loop () {  

  if (Serial.available () > 0) {
    
      incomingByte = Serial.read ();

      str1[count] = incomingByte;
      count++;

      if (count > 49 || incomingByte == 10 || incomingByte == 13) {
          Serial.print (str1);
      
          digitalWrite(13, HIGH);
          delay(200);
          digitalWrite(13, LOW);
          
          count = 0;
      }
  }
}

I send via my program the integer 13
and i receive it by using Serial.print (str1);

but now the str1 also need to be used for the
digitalWrite(13, HIGH);

So i tryed to use:

digitalWrite(str1, HIGH);

it didnt work... >:(

i tryed to use:

int str1;
digitalWrite(str1, HIGH);

but it still doesnt work, im out of options please help!!! :cry:

Thanks,

Christian

If I understand what you are trying to do correctly, you need to convert the string to int

digitalWrite takes an int as the first argument, you can't pass a string

digitalWrite(int, HIGH);

:slight_smile:

Hello,

I tryed using:

int str1;
digitalWrite (str1, HIGH);

and it didnt work :frowning: but indeed i want to make it from a string to a integer. It is possible i think too much in perl :slight_smile: but please help me :-*

Can it be that the string i send mayby still contains the 0A (clear line) bit?

Thanks,

Christian

Solved The Problem!!!

Thnx!!!

Read the C manual atof(3), atoi(3), atol(3), strtod(3), strtoul(3)

NAME
atoi, atol, atoll, atoq - convert a string to an integer

SYNOPSIS
#include <stdlib.h>

int atoi(const char *nptr);
long atol(const char *nptr);
long long atoll(const char *nptr);
long long atoq(const char *nptr);

:slight_smile:

yes yes but i solved it already :wink: using the char* conversation :slight_smile: i can controll all pins now :O) thnx!!!

Ok, cool :slight_smile:

We posted at about the same time, I didn't see your reply as I was replying

:slight_smile:

23:39:09
23:40:29

Hehehe indeed! :wink: It's working great!! I tryed it with 9 leds and its going perfect!

I can now simple send data from my pc to the arduino in perl for controlling the arduino board. I still need to do some research and make some controll bits to tell it for going on or out. But thats all for later :slight_smile:

Just have the arduino for ONE day now :wink: And it worked like i hoped!!! Im not THAT good in C code but it looks a bit like perl :slight_smile:

Thanks again!!!

Christian

PS is there a possibility to use a SPLIT function??

Unfortunately C doesn't have a split function

You have to use strtok()

NAME
strtok, strtok_r - extract tokens from strings

SYNOPSIS
#include <string.h>

char *strtok(char *str, const char *delim);

char *strtok_r(char *str, const char *delim, char **saveptr);

Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

strtok_r(): _SVID_SOURCE || _BSD_SOURCE || _POSIX_C_SOURCE ||
_XOPEN_SOURCE

DESCRIPTION
The strtok() function parses a string into a sequence of tokens. On
the first call to strtok() the string to be parsed should be specified
in str. In each subsequent call that should parse the same string, str
should be NULL.

:slight_smile:

Or you can wait for the Perlduino(TM) :smiley:

Or you can wait for the Perlduino(TM)

Would be fun!!! :slight_smile:

Greetings,

Christian

Hey GNU_Linux!

Got the arduino stable with data for now :wink: See:

C:\htdocs\public_html>perl arduino.cgi
SEND --! 6EVJ9XC23U
RECV !-- 6EVJ9XC23U (Time: 0.025125 Seconds)
SEND --! EWLIEVSHVG
RECV !-- EWLIEVSHVG (Time: 0.018168 Seconds)
SEND --! HGKGWDBPRQ
RECV !-- HGKGWDBPRQ (Time: 0.022339 Seconds)
SEND --! A6BY37FYVY
RECV !-- A6BY37FYVY (Time: 0.023711 Seconds)
SEND --! S21GF32DTM
RECV !-- S21GF32DTM (Time: 0.015003 Seconds)
SEND --! J7HWYDJOXJ
RECV !-- J7HWYDJOXJ (Time: 0.023627 Seconds)
SEND --! 2XPGQFZFJA
RECV !-- 2XPGQFZFJA (Time: 0.016451 Seconds)
SEND --! RT3KF0ERRQ
RECV !-- RT3KF0ERRQ (Time: 0.025205 Seconds)
SEND --! FGPHKW2U5T
RECV !-- FGPHKW2U5T (Time: 0.013038 Seconds)
SEND --! RK1DXZT32P
RECV !-- RK1DXZT32P (Time: 0.017056 Seconds)
SEND --! 9A5JRFLR5W
RECV !-- 9A5JRFLR5W (Time: 0.013702 Seconds)

C:\htdocs\public_html>

PS Do you know something about an AD converters and how to setup with the arduino?!

Manny thanks!

Christian

Cool, cool :slight_smile:

I know some C and some Perl but I am not very good with A/D converters yet

These links may help you :slight_smile:

Hello GNU_Linux,

Thanks voor your help!!! I will try those links you gave, mayby i can use it in my test. I still want to try to make a metall detector running by perl and the arduino. Beqourse it should be possible, im not that long bussy with electronics. I have this idear for around 2 years now
and i just have received the arduino for a week or so? See first post. Im collecting as much electronics for now and have already some nice things but the most is smd. Resistors, Leds, Coils and other. Im now bussy with electronics for several months but never tried anything. Till now with the arduino. I also dont know anything that is standard :slight_smile: mayby it will help!! :stuck_out_tongue: LOL

About programming in perl is what i did the last couple of years i think uhm 14 years??? im now 26 yo :slight_smile: Time for electronics :slight_smile:

Thanks,

Christian

Check this out http://www.instructables.com/id/Home-Made-BFO-metal-detector/

Best of luck :slight_smile:

Neh... (No...) Not that crap :wink:

I got 5 metal detectors 2x Whites DFX a Whites Surfmaster a
Whites TM808 and a Minelab Excalibur 1000

I want to make a vlf or a pulse induction but with the use of the arduino So that i have 10% of hardware and 90% of software :slight_smile:

Greetings & Thanks,

Christian
The Netherlands

About the SPLIT Function, i didnt use the split like you said, i have a betther way using bytes. like the first 3 bytes as a command second 2 bytes as pin number and the last byte as a on/off byte and the rest as message or not used. works fine that way!!

Thanks again!!!

Christian

See:

C:\htdocs\public_html>perl arduino.cgi
SEND --! LED131
RECV !-- LED PIN ON (Time: 0.024898 Seconds)
SEND --! LED130
RECV !-- LED PIN OFF (Time: 0.014133 Seconds)
SEND --! LED131
RECV !-- LED PIN ON (Time: 0.024005 Seconds)
SEND --! LED130
RECV !-- LED PIN OFF (Time: 0.026419 Seconds)
SEND --! LED131
RECV !-- LED PIN ON (Time: 0.020511 Seconds)
SEND --! LED130
RECV !-- LED PIN OFF (Time: 0.017503 Seconds)
SEND --! LED131
RECV !-- LED PIN ON (Time: 0.024201 Seconds)
SEND --! LED130
RECV !-- LED PIN OFF (Time: 0.025929 Seconds)
SEND --! LED131
RECV !-- LED PIN ON (Time: 0.018021 Seconds)
SEND --! LED130
RECV !-- LED PIN OFF (Time: 0.017593 Seconds)
Terminating on signal SIGINT(2)

C:\htdocs\public_html>

Yes! Got a simple metall detector running by the arduino! YES YES YES it works!!!

Ill post images later in a new post!

Greets and Thanks Christian