Go Down

Topic: Pins Are there ever enough (Read 994 times) previous topic - next topic

woody_unreal

Ok im thinking about getting into the networking side (Arduino Ethernet Shield w/o PoE Module) Im running the UNO , I have All 6 Analog pin used for sensors. Im running a stepper motor (8,9,10,11) A LCD 16x4 (7, 6, 5, 4, 3, 2) and of course 13 is usally Onboard LED.
So if im reading the info correctly the Shield uses (11, 12, and 13)
Quote
pin 10 is used to select the W5100 and pin 4 for the SD card

I was thinking if i move a few around i could use (1,2) as outputs for something like the LCD. Are those pins kinda dedicated as TX/RX ?
Or are they a typical pin until , say something in Wire.h Library changes there state?
- could get a shift register
- could do away with LCD since could see data over network
- could drop a sensor
Whats the thoughts /recommendation :) ?

kf2qd

Pins 0 & 1 are used for serial.

No matter how many pins you have you will eventually run out as you add more and more stuff. BUT what is ram doing? how much of that do you have left with all these devices? I would think that you need to look at that also.

You might try splitting your application among several 328's, instead of loading it all on the one. More I/O , and setup communication among them.

woody_unreal

it was a possability, already have 2 UNOs here- not exactly beside each other, The main UNO only has 126 lines of code, Hmm i guess for testing i could use the Wire setup, and see what things i can get into, then if all goes well work on the shield.

woody_unreal

what is the primary difference between Master Writer/Slave Receiver and Master Reader/Slave Sender

pYro_65

Quote
Master Writer/Slave Receiver and Master Reader/Slave Sender


exactly what they say.

one is a Master Writer or if viewed from the slave, a Slave Receiver

the other is the Master Reader or if viewed from the slave, a Slave Sender

the master and slave handle the protocol differently.

CrossRoads

So go with a bigger chip,  the '1284.
32 IO total.
I have a PCB board that is like a duemilanove, populate it with almost all thru hole parts for easy assembly.
Plug in your shield & go.
Will post a pic tonight, or browse the "atmega1284: IDE 1.0 end to end" thread, the last couple of pages.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

woody_unreal

Increasing the amount of pins s one way to go... But nothing like a uncharted challange - fiddling with multiple units (since i have 2 UNOs) http://arduino.cc/forum/index.php/topic,98532.0.html
love the next progresion, but it may turn out not to be the way to go.

woody_unreal

ok maybe this is the wrong line of thinking or the wrong terminology but I was thinking i was passing along a command between master and slave, But it seems thats not how it works, you are passing along a Value (x = 1;) in this code and in turn the Slave is taking that value and changing it into a command (if (x == 1)). So here is my Code
For master
Code: [Select]
#include <Wire.h>

#define LED_PIN 13
byte x = 0;
int  ButtonState = 7;
int Button = 0 ;


void setup()
{
  Wire.begin(); // Start I2C Bus as Master
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, LOW);
  pinMode(ButtonState, INPUT);

}
void loop()
{
  Button = digitalRead(ButtonState);
  if (Button == HIGH)
    {
      x = 0;
    }
    if (Button == LOW)
    {
     
    }
  Wire.beginTransmission(9); // transmit to device #9
  Wire.write(x);              // sends x
  Wire.endTransmission();    // stop transmitting
// x++;
  if (x > 5) x=0;
  delay(450);
}

And here is the one for slave

Code: [Select]
#include <Wire.h>

#define LED_PIN 13
#define LED_1 12
#define LED_2 11

int x;

void setup() {
  Wire.begin(9);                // Start I2C Bus as a Slave (Device Number 9)
  Wire.onReceive(receiveEvent); // register event
 
  pinMode(LED_PIN, OUTPUT);
  pinMode(LED_1, OUTPUT);
  pinMode(LED_2, OUTPUT);
 
  digitalWrite(LED_PIN, LOW);
  digitalWrite(LED_1, LOW);
  digitalWrite(LED_2, LOW);
 
  x = 0;
}

void loop() {
  //If value received is 0 blink LED 1
  if (x == 0) {
    digitalWrite(LED_1, HIGH);
    delay(200);
    digitalWrite(LED_1, LOW);
    delay(200);
  }
  //If value received is 1 blink LED 2
  if (x == 1) {
    digitalWrite(LED_2, HIGH);
    delay(200);
    digitalWrite(LED_2, LOW);
    delay(200);
  }
}

void receiveEvent(int howMany) {
  x = Wire.read();    // receive byte as an integer
}

I used some copied coding But Expanded with button state.
So  Now i would just mostly have to divide Code between the UNOs Correct - Like this one takes care of Say Actions ( Relays that type),
And the othere would take care of Readings to be passed along.
OK so here is another questionDo you have to use
Code: [Select]
Wire.beginTransmission(9);
  Wire.write(x);               
  Wire.endTransmission();

Per Send  or can you do something like
Code: [Select]
Wire.beginTransmission();
Wire.write(x);
Wire.write(y);
Wire.write(z);
Wire.endTransmission();

CrossRoads

Here's the '1284 design I have out now, $4.50 a board, all thru hole except for voltage regulators and USB power fuse.
Intent is to be a '1284 Uno.

FTDI connection can be offboard FTDI Basic or similar, or Mikroelectronika module mounted on board, or not at all.
http://www.mouser.com/ProductDetail/mikroElektronika/MIKROE-483/?qs=jBNCx3lXxWtjl8%2f2BoDrlasLg78nMEX%252b
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

woody_unreal


Nick Gammon

A port-expander will give you more pins. You can set them to input or output, and use I2C to talk to them.

http://www.gammon.com.au/forum/?id=10945

Quote
But it seems thats not how it works, you are passing along a Value (x = 1;) in this code and in turn the Slave is taking that value and changing it into a command (if (x == 1)).


I have a post here that shows how you can hook up an LCD using a port expander. That reduces the number of pins dedicated to the LCD to 2 (SDA/SCL).

http://www.gammon.com.au/forum/?id=10940
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

woody_unreal

thats always a possablity, - Ill see how much i can accomplish with I2C :)
And 2 UNOs :)

Go Up