Hello,
ive found some tutorials that use the Arduino-Pins for Analog and Digital Inputs and Outputs.
The Problem is that i cant find Projects that let me use ALL pins as digital inputs.
So ive tried to modify one project.
The Sketch on the Arduino looks like that:
My Problem is, that i can use pin 2-9 without problems but when the pinnumber is bigger than 9 the pin is not useable/changing states.
LinuxCNC is listing me all Pins but 10-13 are shown as "LOW".
The second problem is, that i cant really figure out what
byteout |= digitalRead(port) << (port-2);
answer or onto digitalRead(port) shift left (higher) this many bits (value of port -2)
so for:
port = 2
port 2 is HIGH
B00000001 = B0000000 | 1 << (2-2 is 0) or B00000001
port = 3
port 3 = HIGH
B00000011 = B0000001 | 1 << (3-2 is 1) or B00000010
port = 4
port 4 = LOW
B00000011 = B0000011 | 0 << (4-3 is 2) or B00000000
port = 5
port 5 = HIGH
B00001011 = B0000011 | 1 << (5-2 is 3) or B00000100
really does..
Could someone help me?
I'm working on interfacing a Arduino MEGA to linuxcnc
// file name udpLCNCMEGA.ino edit for using pin 10 or not. I modded my ethernet W5100 to use pin 53 instead of pin10
// I can't find in the arduino source if that matters.
// look below for
// file udpioMEGA.hal edit for your IP numbers
// file updioMEGA.py edit for your IP numbers
// file define.h for Arduino edit your IP numbers
const float pi=3.14159265358979;
//#include <Encoder.h>
#include <SPI.h> // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <EthernetUdp.h> // UDP library from: bjoern@cs.stanford.edu 12/30/2008
#includ
Get the complete file from MEGAEtherStepperANDOTHERFILES.ino - Pastebin.com
*/
[/quote]
Robin2:
Why not something like this pseudo code
for (byte n = 2; n < 13; n++) { // change the range to suit your requirement
pinVal[n] = digitalRead(n);
}
Serial.print("<");
for (byte n = 2; n < 13; n ++) {
Serial.print(pinVal[n]);
Serial.print(",");
}
Serial.print(">");
That will send all the values like this "<1,0,0,1,....>"
The Python program can then do what it needs to with them.
This [Python-Arduino demo](http://forum.arduino.cc/index.php?topic=225329.msg1810764#msg1810764) may be useful
...R