Pages: [1]   Go Down
Author Topic: Pins Are there ever enough  (Read 736 times)
0 Members and 1 Guest are viewing this topic.
WV
Offline Offline
Full Member
***
Karma: 0
Posts: 160
Arduino, Helps With the ADD
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley ?
Logged

South Texas
Offline Offline
Edison Member
*
Karma: 8
Posts: 1023
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

WV
Offline Offline
Full Member
***
Karma: 0
Posts: 160
Arduino, Helps With the ADD
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

WV
Offline Offline
Full Member
***
Karma: 0
Posts: 160
Arduino, Helps With the ADD
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

North Queensland, Australia
Offline Offline
Edison Member
*
Karma: 53
Posts: 1785
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 439
Posts: 23730
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

WV
Offline Offline
Full Member
***
Karma: 0
Posts: 160
Arduino, Helps With the ADD
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

WV
Offline Offline
Full Member
***
Karma: 0
Posts: 160
Arduino, Helps With the ADD
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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:
#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:
Wire.beginTransmission(9);
  Wire.write(x);               
  Wire.endTransmission();
Per Send  or can you do something like
Code:
Wire.beginTransmission();
Wire.write(x);
Wire.write(y);
Wire.write(z);
Wire.endTransmission();
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 439
Posts: 23730
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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


* Atmega1284_thruhole_pcb.jpg (465.83 KB, 1824x663 - viewed 17 times.)

* ATMega1284_thruhole_sch1.png (80.48 KB, 2444x1233 - viewed 8 times.)
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

WV
Offline Offline
Full Member
***
Karma: 0
Posts: 160
Arduino, Helps With the ADD
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Lol Anyone smiley ?
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

WV
Offline Offline
Full Member
***
Karma: 0
Posts: 160
Arduino, Helps With the ADD
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: