Pages: [1]   Go Down
Author Topic: connect pic with arduino  (Read 241 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello guys
I want to connect my pic18f with arduino mega. when i sent HIGH from the pic i want arduino to read it and and execute a command. Can you help me with the code please.
I tried this code but without result.
Code:
int inPin = 22;   // choose the input pin
int val = 0;     // variable for reading the pin status
void setup()
{
pinMode(inPin, INPUT);
}
void loop()
{
val = digitalRead(inPin);  // read input value
if (val == HIGH) {
// execution of this command
}
}
Thank you
« Last Edit: December 05, 2012, 07:47:44 am by marios_ » Logged

UK
Offline Offline
Faraday Member
**
Karma: 16
Posts: 2883
Gorm deficient
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What's the problem?
Have you connected the grounds together?
Logged

Per Arduino ad Astra

New Jersey
Offline Offline
Faraday Member
**
Karma: 50
Posts: 3429
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I tried this code but without result.
What were you expecting?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46240
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That code does something. You expect it to do something. What either of those somethings is is a mystery, though. Ball's back in your court.

You did connect the grounds, right?
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 121
Posts: 8458
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I tried this code but without result.
You aren't executing any code when you detect the high input

Code:
if (val == HIGH) {
// execution of this command
}

What did you expect to see from a comment?

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Pages: [1]   Go Up
Jump to: