AquaticTechTank.net

A forum dedicated to design and program aquatic tanks
It is currently Wed Jan 17, 2018 3:57 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Mon Feb 25, 2013 6:22 pm 
Offline
Site Admin

Joined: Fri Nov 30, 2012 1:54 pm
Posts: 275
For those curious what ISP is, it stands for 'In System-programer'. It's a way for you to use the arduino board to program AVR chips (ATmega to ATtiny). Say you built an application with the arduino but don't want to use an expensive arduino to run it, you can program these chips ($2-$4) to run your application. You can use your ardunio to prototype.


I want to build a I2C interface for series of relays base on this project that uses the tiny85.
http://www.forkrobotics.com/2012/05/rel ... -over-i2c/

Luckily I don't need any new libraries since the tiny2313 is included in the library.
I found a project for the 2313 here
http://www.ernstc.dk/arduino/2313.htm

This was my setup.
Image

I added the LEDs as indicator of the health of the upload. I was having trouble with the Arduino recognizing the tiny2313. It turned out I just need to push the darn chip down harder to make contact.

Attachment:
2313.jpg
2313.jpg [ 25.47 KiB | Viewed 2170 times ]


Top
 Profile  
 
PostPosted: Mon Feb 25, 2013 6:28 pm 
Offline
Site Admin

Joined: Fri Nov 30, 2012 1:54 pm
Posts: 275
I then uploaded the I2C control onto the 2313
Code:
#include "TinyWireS.h"                  // wrapper class for I2C slave routines
 
#define I2C_SLAVE_ADDR  0x26            // i2c slave address
#define Relay1_PIN  2
#define Relay2_PIN  3
#define Relay3_PIN  4
#define Relay4_PIN  5
#define Relay5_PIN  6
#define Relay6_PIN  7

 
void setup(){
  pinMode(Relay1_PIN,OUTPUT);
  pinMode(Relay2_PIN,OUTPUT);
  pinMode(Relay3_PIN,OUTPUT);
  pinMode(Relay4_PIN,OUTPUT);
  pinMode(Relay5_PIN,OUTPUT);
  pinMode(Relay6_PIN,OUTPUT);
  TinyWireS.begin(I2C_SLAVE_ADDR);      // init I2C Slave mode
}
 
void loop(){
  byte byteRcvd = 0;
  if (TinyWireS.available()){           // got I2C input!
    byteRcvd = TinyWireS.receive();     // get the byte from master
      switch (byteRcvd) {
        case 0x01:
          Switch(Relay1_PIN);
        break;
        case 0x02:
          Switch(Relay2_PIN);
        break;
        case 0x03:
          Switch(Relay3_PIN);
        break;
         case 0x04:
          Switch(Relay4_PIN);
        break;
        case 0x05:
          Switch(Relay5_PIN);
        break;
        case 0x06:
          Switch(Relay6_PIN);
        break;
      }
 
  }
}
 
void Switch(int relay){
    if (digitalRead(relay) == HIGH){ digitalWrite(relay,LOW);}
    else {digitalWrite(relay,HIGH);}
}


Pin B5/17 is used for SDA
Pin B7/19 is used for SCL



The Pins used to control the LED isn't what I expected but hey, it works :)
I'm off by 2 in the pins down in the chart. I'm not sure why.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Copyright 2noodles LLC 2012