Simple Question and YES i got my Arduino!!!


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 = ();

      str1[count] = incomingByte;

      if (count > 49 || incomingByte == 10 || incomingByte == 13) {
          Serial.print (str1);
          digitalWrite(13, HIGH);
          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:



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);



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?



Solved The Problem!!!


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

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

#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);


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



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!!!


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

Unfortunately C doesn't have a split function

You have to use strtok()

strtok, strtok_r - extract tokens from strings

#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)):


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.


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

Or you can wait for the Perlduino(TM)

Would be fun!!! :slight_smile:



Hey GNU_Linux!

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

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


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

Manny thanks!


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:



Check this out

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,

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!!!



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)


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