Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8020467

Browse files
committed
attach process to analog pin
1 parent e78dafa commit 8020467

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

analog_access.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,32 @@ Analog_In::Analog_In()
2323
}
2424
}
2525

26+
bool Analog_In::attach(unsigned char pin_num)
27+
{
28+
char analog_input[4];
29+
char dummy_input[4];
30+
31+
if(!is_attached)
32+
{
33+
34+
if(pin_num == '0' || pin_num == '1' || pin_num == '2' || pin_num == '3' || pin_num == '4' || pin_num == '5')
35+
{
36+
len = snprintf(analog_Path,sizeof(analog_Path),ANALOG_SYSPATH"%c",pin_num);
37+
is_attached = 1;
38+
analog_pinNum = pin_num;
39+
analog_makeUnAvailable(pin_num);
40+
return 1;
41+
}
42+
else
43+
{
44+
cout<<"Wrong Pin Number\n";
45+
return 0;
46+
}
47+
}
48+
else
49+
{
50+
cout<<"Pin already Attached\n";
51+
return 0;
52+
}
53+
}
2654

0 commit comments

Comments
 (0)