element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • Product Groups
  • Store
    Store
    • Visit Your Store
    • Choose Another Store
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
Arduino
  • Products
  • More
Arduino
Blog Arduino Mega 2560 attached to Cetipede sheild
  • Blog
  • Forum
  • Documents
  • Events
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Arduino requires membership for participation - click to join
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Former Member
  • Date Created: 25 Jan 2014 2:45 PM Date Created
  • Views 1223 views
  • Likes 0 likes
  • Comments 6 comments
  • arduino
Related
Recommended

Arduino Mega 2560 attached to Cetipede sheild

Former Member
Former Member
25 Jan 2014

I am trying to search for a code to couple the Centipede to the Arduino Mega2560, using the Cetipede 64 pin to work with a simple programme such as 1 input on the Mega and sequence of timings;

 

int pin2 = 2;
int pin3 = 3;
int pin4 = 4;
int pin5 = 5;
int pin6 = 6;
int pin7 = 7;
int pin8 = 8;
int pin9 = 9;
int pin10 = 10;
int pin11 = 11;
int pin12 = 12;
int pin13 = 13;
int pin14 = 14;
int pin15 = 15;
int pin16 = 16;
int pin17 = 17;
int pin18 = 18;
int pin19 = 19;
int pin20 = 20;
int pin21 = 21;
int pin22 = 22;
int pin23 = 23;
int pin24 = 24;
int pin25 = 25;
int timer1 = 500;
int timer2 = 500;
int timer3 = 500;
int val = 0;
int state = HIGH; // the current state of the output pin
int reading; // the current reading from the input pin
int previous = LOW; // the previous reading from the input pin
long time = 0; // the last time the output pin was toggled
long debounce = 200; // the debounce time, increase if the output flickers
int interval = 500;
void setup(){
pinMode(pin2, OUTPUT);
pinMode(pin3, OUTPUT);
pinMode(pin4, OUTPUT);
pinMode(pin5, OUTPUT);
pinMode(pin6, OUTPUT);
pinMode(pin7, OUTPUT);
pinMode(pin8, OUTPUT);
pinMode(pin9, OUTPUT);
pinMode(pin10, OUTPUT);
pinMode(pin11, OUTPUT);
pinMode(pin12, OUTPUT);
pinMode(pin13, OUTPUT);
pinMode(pin14, OUTPUT);
pinMode(pin15, OUTPUT);
pinMode(pin16, OUTPUT);
pinMode(pin17, OUTPUT);
pinMode(pin18, OUTPUT);
pinMode(pin19, OUTPUT);
pinMode(pin20, OUTPUT);
pinMode(pin21, OUTPUT);
pinMode(pin22, OUTPUT);
pinMode(pin23, OUTPUT);
pinMode(pin24, INPUT);
pinMode(pin25, INPUT);
}
void loop() {
reading = digitalRead(pin25);
// if the input just went from LOW and HIGH and we've waited long enough
// to ignore any noise on the circuit, toggle the output pin and remember
// the time
if (reading == HIGH && previous == LOW && millis() - time > debounce) {
// ... invert the output
if (state == HIGH)
state = LOW;
else
state = HIGH;
// ... and remember when the last button press was
time = millis();

digitalWrite(pin12, HIGH);
digitalWrite(pin10, HIGH);
delay(timer3);
digitalWrite(pin2, HIGH);
delay(timer1);

digitalWrite(pin3, HIGH);
delay(timer1);
digitalWrite(pin2, LOW);

digitalWrite(pin4, HIGH);
delay(timer1);
digitalWrite(pin3, LOW);

digitalWrite(pin5, HIGH);
delay(timer1);
digitalWrite(pin4, LOW);

digitalWrite(pin6, HIGH);
delay(timer1);
digitalWrite(pin5, LOW);

digitalWrite(pin7, HIGH);
delay(timer1);
digitalWrite(pin6, LOW);

digitalWrite(pin8, HIGH);
delay(timer1);
digitalWrite(pin7, LOW);

digitalWrite(pin9, HIGH);
delay(timer1);
digitalWrite(pin8, LOW);
delay(timer1);
digitalWrite(pin9, LOW);
digitalWrite(pin10, LOW);
digitalWrite(pin12, LOW);
delay(timer2);
}

//round2
reading = digitalRead(pin24);
// if the input just went from LOW and HIGH and we've waited long enough
// to ignore any noise on the circuit, toggle the output pin and remember
// the time
if (reading == HIGH && previous == LOW && millis() - time > debounce) {
// ... invert the output
if (state == HIGH)
state = LOW;
else
state = HIGH;
// ... and remember when the last button press was
time = millis();


digitalWrite(pin13, HIGH);
digitalWrite(pin11, HIGH);
delay(timer3);
digitalWrite(pin2, HIGH);
digitalWrite(pin9, HIGH);
delay(timer1);

digitalWrite(pin3, HIGH);
digitalWrite(pin8, HIGH);
delay(timer1);
digitalWrite(pin2, LOW);
digitalWrite(pin9, LOW);

digitalWrite(pin4, HIGH);
digitalWrite(pin7, HIGH);
delay(timer1);
digitalWrite(pin3, LOW);
digitalWrite(pin8, LOW);

digitalWrite(pin5, HIGH);
digitalWrite(pin6, HIGH);
delay(timer1);
digitalWrite(pin4, LOW);
digitalWrite(pin7, LOW);

delay(timer1);
digitalWrite(pin5, LOW);
digitalWrite(pin6, LOW);

digitalWrite(pin11, LOW);
digitalWrite(pin13, LOW);
delay(timer2);
}
}

 

Hope I get a reply, I am messed up.

  • Sign in to reply
Parents
  • Former Member
    Former Member over 9 years ago

    // Example code for Centipede Library
    // Works with Centipede Shield or MCP23017 on Arduino I2C port

    #include <Wire.h>
    #include <Centipede.h>


    /* Available commands
      .digitalWrite([0...127], [LOW...HIGH]) - Acts like normal digitalWrite
      .digitalRead([0...127]) - Acts like normal digitalRead
      .pinMode([0...127], [INPUT...OUTPUT]) - Acts like normal pinMode
      .portWrite([0...7], [0...65535]) - Writes 16-bit value to one port (chip)
      .portRead([0...7]) - Reads 16-bit value from one port (chip)
      .portMode([0...7], [0...65535]) - Write I/O mask to one port (chip)
      .pinPullup([0...127], [LOW...HIGH]) - Sets pullup on input pin
      .portPullup([0...7], [0...65535]) - Sets pullups on one port (chip)
      .init() - Sets all registers to initial values

      Examples
      CS.init();
      CS.pinMode(0,OUTPUT);
      CS.digitalWrite(0, HIGH);
      int recpin = CS.digitalRead(0);
      CS.portMode(0, 0b0111111001111110); // 0 = output, 1 = input
      CS.portWrite(0, 0b1000000110000001); // 0 = LOW, 1 = HIGH
      int recport = CS.portRead(0);
      CS.pinPullup(1,HIGH);
      CS.portPullup(0, 0b0111111001111110); // 0 = no pullup, 1 = pullup
    */

    Centipede CS; // create Centipede object
    int pin8=8;

    void setup()
    {
      Wire.begin(); // start I2C

      CS.initialize(); // set all registers to default

      CS.portMode(0, 0b0000000000000000); // set all pins on chip 0 to output

      //TWBR = 12; // uncomment for 400KHz I2C (on 16MHz Arduinos)
    pinMode(pin8, OUTPUT);
    }


    void loop()
    { 
    CS.digitalWrite (pin8, HIGH);
      }

     

    I think something is missing, the i2c not specified, still confused?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • Former Member
    Former Member over 9 years ago

    // Example code for Centipede Library
    // Works with Centipede Shield or MCP23017 on Arduino I2C port

    #include <Wire.h>
    #include <Centipede.h>


    /* Available commands
      .digitalWrite([0...127], [LOW...HIGH]) - Acts like normal digitalWrite
      .digitalRead([0...127]) - Acts like normal digitalRead
      .pinMode([0...127], [INPUT...OUTPUT]) - Acts like normal pinMode
      .portWrite([0...7], [0...65535]) - Writes 16-bit value to one port (chip)
      .portRead([0...7]) - Reads 16-bit value from one port (chip)
      .portMode([0...7], [0...65535]) - Write I/O mask to one port (chip)
      .pinPullup([0...127], [LOW...HIGH]) - Sets pullup on input pin
      .portPullup([0...7], [0...65535]) - Sets pullups on one port (chip)
      .init() - Sets all registers to initial values

      Examples
      CS.init();
      CS.pinMode(0,OUTPUT);
      CS.digitalWrite(0, HIGH);
      int recpin = CS.digitalRead(0);
      CS.portMode(0, 0b0111111001111110); // 0 = output, 1 = input
      CS.portWrite(0, 0b1000000110000001); // 0 = LOW, 1 = HIGH
      int recport = CS.portRead(0);
      CS.pinPullup(1,HIGH);
      CS.portPullup(0, 0b0111111001111110); // 0 = no pullup, 1 = pullup
    */

    Centipede CS; // create Centipede object
    int pin8=8;

    void setup()
    {
      Wire.begin(); // start I2C

      CS.initialize(); // set all registers to default

      CS.portMode(0, 0b0000000000000000); // set all pins on chip 0 to output

      //TWBR = 12; // uncomment for 400KHz I2C (on 16MHz Arduinos)
    pinMode(pin8, OUTPUT);
    }


    void loop()
    { 
    CS.digitalWrite (pin8, HIGH);
      }

     

    I think something is missing, the i2c not specified, still confused?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2023 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • Facebook
  • Twitter
  • linkedin
  • YouTube