https://www.chowmainsoft.com/arduino
int digitalState[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; void setup() {
// put your setup code here, to run once:
Serial.begin(9600); for (int i = 2; i < 13; i++) {
//pinMode(i, INPUT);
pinMode(i, INPUT_PULLUP);
}
} void loop() {
// put your main code here, to run repeatedly:
for (int i = 2; i < 13; i++) {
int sensorVal = digitalRead(i);
if (digitalState[i - 1] != sensorVal) {
digitalState[i - 1] = sensorVal;
if (i < 10) {
Serial.println('0' + String(i) + String(sensorVal));
}
else
{
Serial.println(String(i) + String(sensorVal));
}
} }
}
lua
<devicedata>
<copyright>Copyright 2015 Chowmain. All rights reserved.</copyright>
<creator>Chowmain</creator>
<name>Arduino Nano Contact Input</name>
<model>NanoContact Input</model>
<manufacturer>Arduino</manufacturer>
<driver>DriverWorks</driver>
<control>lua_gen</control>
<version>001</version>
<created>11/02/2015 12:00:00 PM</created>
<modified>11/02/2015 12:00:00 PM</modified>
<front>{Width=700, Height=336}\x158DVPX777-f.bmp</front>
<back>{Width=500, Height=250}\x158dvpx777-b.bmp</back>
<proxy>Driverworks_Arduino_Nano</proxy>
<states/>
<config>
<documentation>
</documentation>
<script>
<![CDATA[
-------------------------------------------------------------------
--Function Name : ReceivedFromSerial
--Parameters : idBinding, strData
--description : Function to give feedback to a light
------------------------------------------------------------------- function ReceivedFromSerial(idBinding, strData)
print("RECEIVED SERIAL DATA: " .. strData)
if(tonumber(string.sub(strData,3,3)) == 0) then --opened
C4:SendToProxy(tonumber(string.sub(strData,1,2)),"OPENED",{}, "NOTIFY")
elseif(tonumber(string.sub(strData,3,3)) == 1) then --close
C4:SendToProxy(tonumber(string.sub(strData,1,2)),"CLOSED",{}, "NOTIFY")
end
end
]]>
</script>
</config>
<connections>
<connection>
<id>1</id>
<facing>6</facing>
<connectionname>Serial RS-232</connectionname>
<type>1</type>
<consumer>True</consumer>
<audiosource>False</audiosource>
<videosource>False</videosource>
<linelevel>False</linelevel>
<classes>
<class>
<classname>RS_232</classname>
</class>
</classes>
</connection>
<connection>
<id>2</id>
<facing>6</facing>
<connectionname>Digital Input 2</connectionname>
<type>1</type>
<consumer>False</consumer>
<audiosource>False</audiosource>
<videosource>False</videosource>
<linelevel>False</linelevel>
<classes>
<class>
<classname>CONTACT_SENSOR</classname>
</class>
</classes>
</connection>
<connection>
<id>3</id>
<facing>6</facing>
<connectionname>Digital Input 3</connectionname>
<type>1</type>
<consumer>False</consumer>
<audiosource>False</audiosource>
<videosource>False</videosource>
<linelevel>False</linelevel>
<classes>
<class>
<classname>CONTACT_SENSOR</classname>
</class>
</classes>
</connection>
<connection>
<id>4</id>
<facing>6</facing>
<connectionname>Digital Input 4</connectionname>
<type>1</type>
<consumer>False</consumer>
<audiosource>False</audiosource>
<videosource>False</videosource>
<linelevel>False</linelevel>
<classes>
<class>
<classname>CONTACT_SENSOR</classname>
</class>
</classes>
</connection>
<connection>
<id>5</id>
<facing>6</facing>
<connectionname>Digital Input 5</connectionname>
<type>1</type>
<consumer>False</consumer>
<audiosource>False</audiosource>
<videosource>False</videosource>
<linelevel>False</linelevel>
<classes>
<class>
<classname>CONTACT_SENSOR</classname>
</class>
</classes>
</connection>
<connection>
<id>6</id>
<facing>6</facing>
<connectionname>Digital Input 6</connectionname>
<type>1</type>
<consumer>False</consumer>
<audiosource>False</audiosource>
<videosource>False</videosource>
<linelevel>False</linelevel>
<classes>
<class>
<classname>CONTACT_SENSOR</classname>
</class>
</classes>
</connection>
<connection>
<id>7</id>
<facing>6</facing>
<connectionname>Digital Input 7</connectionname>
<type>1</type>
<consumer>False</consumer>
<audiosource>False</audiosource>
<videosource>False</videosource>
<linelevel>False</linelevel>
<classes>
<class>
<classname>CONTACT_SENSOR</classname>
</class>
</classes>
</connection>
<connection>
<id>8</id>
<facing>6</facing>
<connectionname>Digital Input 8</connectionname>
<type>1</type>
<consumer>False</consumer>
<audiosource>False</audiosource>
<videosource>False</videosource>
<linelevel>False</linelevel>
<classes>
<class>
<classname>CONTACT_SENSOR</classname>
</class>
</classes>
</connection>
<connection>
<id>9</id>
<facing>6</facing>
<connectionname>Digital Input 9</connectionname>
<type>1</type>
<consumer>False</consumer>
<audiosource>False</audiosource>
<videosource>False</videosource>
<linelevel>False</linelevel>
<classes>
<class>
<classname>CONTACT_SENSOR</classname>
</class>
</classes>
</connection>
<connection>
<id>10</id>
<facing>6</facing>
<connectionname>Digital Input 10</connectionname>
<type>1</type>
<consumer>False</consumer>
<audiosource>False</audiosource>
<videosource>False</videosource>
<linelevel>False</linelevel>
<classes>
<class>
<classname>CONTACT_SENSOR</classname>
</class>
</classes>
</connection>
<connection>
<id>11</id>
<facing>6</facing>
<connectionname>Digital Input 11</connectionname>
<type>1</type>
<consumer>False</consumer>
<audiosource>False</audiosource>
<videosource>False</videosource>
<linelevel>False</linelevel>
<classes>
<class>
<classname>CONTACT_SENSOR</classname>
</class>
</classes>
</connection>
<connection>
<id>12</id>
<facing>6</facing>
<connectionname>Digital Input 12</connectionname>
<type>1</type>
<consumer>False</consumer>
<audiosource>False</audiosource>
<videosource>False</videosource>
<linelevel>False</linelevel>
<classes>
<class>
<classname>CONTACT_SENSOR</classname>
</class>
</classes>
</connection>
</connections>
<capabilities>
<serialsettings>9600 8 none 1 none</serialsettings>
</capabilities>
</devicedata>