Show Posts
Pages: [1]
1  Topics / Home Automation and Networked Objects / html font size on: November 06, 2012, 09:48:56 pm
          Im having some trouble changing the font size of the word START tried a few things but couldn't seem to get it to work. Any ideas?

client.print("<input type=submit value=START style=width:500px;height:250px onClick=location.href='/?on2'>");
2  Using Arduino / Networking, Protocols, and Devices / Re: need help with 1 master arduino and 2 slave for car wiring harness on: September 24, 2012, 07:29:59 pm
how exactly would i modify the code
3  Using Arduino / Networking, Protocols, and Devices / Re: need help with 1 master arduino and 2 slave for car wiring harness on: September 21, 2012, 05:54:55 pm
what all would i need to do to use rs485
4  Using Arduino / Networking, Protocols, and Devices / Re: need help with 1 master arduino and 2 slave for car wiring harness on: September 20, 2012, 01:58:38 pm
well i got it all figured out but what do you mean its not a receipt for a reliable system
for master i have
Quote
#include <Wire.h>

#define LIGHTS_PIN 2      // Pin 2 on local
#define FANS_PIN 3      // Pin 3 on local
#define HORNS_PIN 4      // Pin 4 on local
#define WIPERS_PIN 5      // Pin 5 on local
#define WASHERS_PIN 6      // Pin 6 on local
#define FOGS_PIN 7      // Pin 7 on local
#define BRAKELIGHTS_PIN 8      // Pin 8 on local
#define LEFTBLKS_PIN 9      // Pin 9 on local
#define RIGHTBLKS_PIN 10     // Pin 10 on local
#define HAZARDS_PIN 11     // Pin 11 on local
 
#define HEADLIGHT_PIN 102     // Pin 2 on remote
#define FAN_PIN 103     // Pin 3 on remote
#define HORN_PIN 104     // Pin 4 on remote
#define WIPER_PIN 105     // Pin 5 on remote
#define WASHER_PIN 106     // Pin 6 on remote
#define FOG_PIN 107     // Pin 7 on remote
#define RIGHTBLK_PIN 108     // Pin 8 on remote


#define TAILIGHT_PIN 112     // Pin 2 on remote
#define BRAKELIGHT_PIN 113     // Pin 3 on remote
#define LICENESLAMP_PIN 114     // Pin 4 on remote
#define RRIGHTBLK_PIN 115     // Pin 5 on remote
#define RLEFTBLK_PIN 116     // Pin 6 on remote




int light = 0;         // variable for reading the pushbutton status
int fan = 0;
int horn = 0;
int wiper = 0;
int washer = 0;
int fog = 0;
int brakelight = 0;
int rightblk = 0;
int leftblk = 0;
int hazard= 0;

void setup()
{

  Wire.begin(); // join i2c bus
}


void loop()
{

  light = digitalRead(LIGHTS_PIN);
  if (light == HIGH) {       
    frontWrite(HEADLIGHT_PIN,HIGH);
    backWrite(TAILIGHT_PIN,HIGH);
    backWrite(LICENESLAMP_PIN,HIGH);
  }
  else {
    frontWrite(HEADLIGHT_PIN,LOW);
    backWrite(TAILIGHT_PIN,LOW);
    backWrite(LICENESLAMP_PIN,LOW);
  }


  hazard = digitalRead(HAZARDS_PIN);
  if (hazard == HIGH) {       
    frontWrite(RIGHTBLK_PIN ,HIGH);
    frontWrite(LEFTBLK_PIN ,HIGH);
    backWrite(RLEFTBLK_PIN,HIGH);
    backWrite(RRIGHTBLK_PIN,HIGH);
  }
  else {
    frontWrite(RIGHTBLK_PIN,LOW);
    frontWrite(LEFTBLK_PIN ,HIGH);
    backWrite(RLEFTBLK_PIN,HIGH);
    backWrite(RRIGHTBLK_PIN,LOW);
  }



  rightblk = digitalRead(RIGHTBLKS_PIN);
  if (rightblk == HIGH) {       
    frontWrite(RIGHTBLK_PIN ,HIGH);
    backWrite(RRIGHTBLK_PIN,HIGH);
  }
  else {
    frontWrite(RIGHTBLK_PIN,LOW);
    backWrite(RRIGHTBLK_PIN,LOW);
  }



  leftblk = digitalRead(LEFTBLKS_PIN);
  if (leftblk == HIGH) {       
    frontWrite(LEFTBLK_PIN ,HIGH);
    backWrite(RLEFTBLK_PIN,HIGH);
  }
  else {
    frontWrite(LEFTBLK_PIN,LOW);
    backWrite(RLEFTBLK_PIN,LOW);
  }






  fan = digitalRead(FANS_PIN);
  if ( fan == HIGH) {       
    frontWrite(FAN_PIN,HIGH);
  }
  else {
    frontWrite(FAN_PIN,LOW);
  }


  horn = digitalRead(HORNS_PIN);
  if ( horn == HIGH) {       
    frontWrite(HORN_PIN,HIGH);
  }
  else {
    frontWrite(HORN_PIN,LOW);
  }


  wiper = digitalRead(WIPERS_PIN);
  if ( wiper == HIGH) {       
    frontWrite(WIPER_PIN,HIGH);
  }
  else {
    frontWrite(WIPER_PIN,LOW);
  }


  washer = digitalRead(WASHERS_PIN);
  if ( washer == HIGH) {       
    frontWrite(WASHER_PIN,HIGH);
  }
  else {
    frontWrite(WASHER_PIN,LOW);
  }


  fog = digitalRead(FOGS_PIN);
  if ( fog == HIGH) {       
    frontWrite(FOG_PIN,HIGH);
  }
  else {
    frontWrite(FOG_PIN,LOW);
  }


  brakelight = digitalRead(BRAKELIGHTS_PIN);
  if ( brakelight == HIGH) {       
    backWrite(BRAKELIGHT_PIN,HIGH);
  }
  else {
    backWrite(BRAKELIGHT_PIN,LOW);
  }


}
void frontWrite(int pin, int value)
{
  pin = pin-100;  // substracts 100 so it maps to the real ports on the expansion arduino
  Wire.beginTransmission(1); // transmit to device #1
  Wire.write(pin);              // sends one byte stating the pin to be addressed
  Wire.write(value);          // sends the value to be transmitted to the pin selected
  Wire.endTransmission();    // stop transmitting
}

void backWrite(int pin, int value)
{
  pin = pin-110;  // substracts 100 so it maps to the real ports on the expansion arduino
  Wire.beginTransmission(2); // transmit to device #2
  Wire.write(pin);              // sends one byte stating the pin to be addressed
  Wire.write(value);          // sends the value to be transmitted to the pin selected
  Wire.endTransmission();    // stop transmitting
}






and for the front slave



Quote
#include <Wire.h>


void setup()
{
  Wire.begin(1);                // join i2c bus with address #1
  Wire.onReceive(receiveEvent); // register event
}


void loop()
{
    // Whatever. maybe nothing.
}



void receiveEvent(int howMany)
{
  int port = Wire.read();    // receive byte as an integer
  int value = Wire.read();   // receives the byte with the value
  digitalWrite(port,value);         // sets the pin to the desired value
}


its the same for the second but i changed the address


so what would be a more reliable way of doing this 
5  Using Arduino / Networking, Protocols, and Devices / need help with 1 master arduino and 2 slave for car wiring harness on: September 12, 2012, 08:04:28 pm
ok so im building a wiring harness for my car using 1 master arduino which will be under the dash and 2 slaves one in the rear and one in the front of the car. all of the inputs will go to the master arduino and all outputs will be conected to the closest slave ex headlight on the front and tail lights on the back arduino im using logic level fetts to power the outputs the code i have so far im not sure i have been doing this right or if theres an easer way to do it but for the blinkers im not sure how to do pwm to get them to blink in the slave code

master

#include <Wire.h>
//all the inputs on the master arduino
#define HEADLIGHT 2
#define LEFTBLK 3
#define RIGHTBLK 4
#define FAN 5
#define WIPER 6
#define HORN 7


#define FRONT 2 //front arduino
#define REAR 3  //rear arduino
#define BOTH 4  // both arduinos front and rear for blinkers

void setup() {
  Serial.begin(112500);           
  pinMode(HEADLIGHT, INPUT); // all inputs for arduinos
  digitalWrite(HEADLIGHT, HIGH);
  pinMode(LEFTBLK, INPUT);
  digitalWrite(LEFTBLK, HIGH);
  pinMode(RIGHTBLK, INPUT);
  digitalWrite(RIGHTBLK, HIGH);
  pinMode(FAN, INPUT);
  digitalWrite(FAN, HIGH);
  pinMode(WIPER, INPUT);
  digitalWrite(WIPER, HIGH);
  pinMode(HORN, INPUT);
  digitalWrite(HORN, HIGH);
  Wire.begin();
}

boolean last_state = HIGH;
void loop() {
  if (digitalRead(HEADLIGHT) != last_state){
    last_state = digitalRead(HEADLIGHT);
    Serial.println("Start");
    Wire.beginTransmission(FRONT);
    Wire.write(last_state);
    Wire.endTransmission();

 
    if (digitalRead(LEFTBLK) != last_state)
      last_state = digitalRead(LEFTBLK);
    Serial.println("Start");
    Wire.beginTransmission(BOTH);
    Serial.println("Beginning transmission");
    Wire.write(last_state);
    Serial.println("Sent Data");
    Wire.endTransmission();
    Serial.println("Ended transmission");
 
 
    if (digitalRead(RIGHTBLK) != last_state)
      last_state = digitalRead(RIGHTBLK);
    Serial.println("Start");
    Wire.beginTransmission(BOTH);
    Serial.println("Beginning transmission");
    Wire.write(last_state);
    Serial.println("Sent Data");
    Wire.endTransmission();
    Serial.println("Ended transmission");
 
 
    if (digitalRead(FAN) != last_state)
      last_state = digitalRead(FAN);
    Serial.println("Start");
    Wire.beginTransmission(FRONT);
    Serial.println("Beginning transmission");
    Wire.write(last_state);
    Serial.println("Sent Data");
    Wire.endTransmission();
    Serial.println("Ended transmission");
  }
}


in not sure how to design the slave codes but i have been going off of this sketch which is not mine


#include <Wire.h>

#define HEADLIGHT 9 // headlight connected to pin 9 through fett
#define FRONT  // address i think should be for the slave to only read whats coming from the outputs on the master designated to go to the front

void setup() {
  pinMode(HEADLIGHT, OUTPUT);
  digitalWrite(HEADLIGHT, LOW);
  Serial.begin(112500);
  Wire.begin(FRONT);
  Wire.onReceive(receiveEvent);
}


void loop() {

}

void receiveEvent(int howMany){ // i have no idea what any of this is
  while (Wire.available() > 0){
    boolean b = Wire.receive();
    digitalWrite(HEADLIGHT, !b);
  }
}

Pages: [1]