/* Copyright 2014 Greg Stein * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // ### docco #include #define TARGET_ADDR 10 //#define LED 9 #define LED 13 void setup(void) { Serial.begin(115200); Wire.begin(); pinMode(LED, OUTPUT); } #define OP_ENABLE 0x20 #define OP_DISABLE 0x00 #define OP_PORTA 0x00 #define OP_PORTC 0x02 static void send_op(uint8_t enable, uint8_t port, uint8_t pin) { uint8_t value = enable | port; switch (pin) { case 0: value |= 0x01; break; case 1: value |= 0x09; break; case 2: value |= 0x04; break; case 3: value |= 0x0C; break; case 4: value |= 0x10; break; case 5: value |= 0x18; break; } // WRITE to the TARGET Wire.beginTransmission(TARGET_ADDR); Wire.write(value); Wire.endTransmission(); // ### check for ACK } void loop(void) { #if 0 digitalWrite(LED, LOW); send_op(OP_ENABLE, OP_PORTA, 4); delay(500); digitalWrite(LED, HIGH); send_op(OP_DISABLE, OP_PORTA, 5); delay(500); digitalWrite(LED, LOW); send_op(OP_ENABLE, OP_PORTC, 1); delay(500); digitalWrite(LED, HIGH); send_op(OP_DISABLE, OP_PORTA, 4); delay(500); digitalWrite(LED, LOW); send_op(OP_ENABLE, OP_PORTC, 0); delay(500); digitalWrite(LED, HIGH); send_op(OP_DISABLE, OP_PORTC, 1); delay(500); digitalWrite(LED, LOW); send_op(OP_ENABLE, OP_PORTA, 5); delay(500); digitalWrite(LED, HIGH); send_op(OP_DISABLE, OP_PORTC, 0); delay(500); #endif #if 1 digitalWrite(LED, HIGH); send_op(OP_ENABLE, OP_PORTA, 0); delay(500); digitalWrite(LED, LOW); send_op(OP_DISABLE, OP_PORTA, 0); delay(500); #endif }