Loading...
  Show Posts
Pages: 1 2 [3] 4 5 ... 7
31  Using Arduino / Installation & Troubleshooting / Sketch working on Mega 2560 R3 but not on R1/2 on: January 06, 2013, 05:09:31 pm
Hi,

my Sketch is working on the Mega 2560 R3 but not on an older one.
I don't know if its an R1 or R2 cause there is no print on the PCB.
I also switched the ethernet shield to make sure its not the shield.

The MQTT Server does not receive the "hello world" from the older Mega 2560.

Code:
#include <SPI.h>
#include <Ethernet.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <PubSubClient.h>

/**************************************************************
*                         Connections                         *
**************************************************************/
#define ONE_WIRE_BUS 5 // oneWire pin is D5

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

/**************************************************************
*                      Ethernet Settings                      *
**************************************************************/
// Ethernet Card Mac Address
byte mac[] = {0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF};
// IPv4 address
byte ip[] = {192, 168, 0, 132};
// Subnet mask
byte subnet[] = {255, 255, 255, 0};
// Default gateway
byte gateway[] = {192, 168, 0, 1};
// MQTT Server
byte server[] = { 192, 168, 0, 1 };
// Preferred DNS sever
// byte dns[] = {192, 168, 0, 1};

/**************************************************************
*                           MQTT                              *
**************************************************************/
void callback(char* topic, byte* payload, unsigned int length)
{

}

// Fire up PubSub client
PubSubClient client(server, 1883, callback);

/**************************************************************
*                           Setup                             *
**************************************************************/
void setup()
{
  byte i;
  byte dsAddress[8];
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
    while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  Serial.println( "Searching for DS18B20..." );
  oneWire.reset_search(); // Start the search with the first device
  if( !oneWire.search(dsAddress) )
  {
    Serial.println( "none found. Using default MAC address." );
  } else {
    Serial.println( "success. Setting MAC address:" );
    Serial.print( " DS18B20 ROM  =" );
    for( i = 0; i < 8; i++)
    {
      Serial.write(' ');
      Serial.print( dsAddress[i], HEX );
    }
    Serial.println();
   
    // Offset array to skip DS18B20 family code, and skip mac[0]
    mac[1] = dsAddress[3];
    mac[2] = dsAddress[4];
    mac[3] = dsAddress[5];
    mac[4] = dsAddress[6];
    mac[5] = dsAddress[7];
  }

  Serial.print( " Ethernet MAC =" );
  for( i = 0; i < 6; i++ )
  {
    Serial.write( ' ' );
    Serial.print( mac[i], HEX );
  }
  Serial.println();

  Ethernet.begin(mac, ip, subnet, gateway);
  Serial.print(" IPv4 address: ");
  Serial.println(Ethernet.localIP());

  // Start up the Dallas Temperature library
  sensors.begin(); // IC Default 9 bit. If you have troubles consider upping it 12. Ups the delay giving the IC more time to process the temperature measurement

   if (client.connect("arduinoClient", "testuser", "testpass")) {
    client.publish("outTopic","hello world");
    client.subscribe("inTopic");
  }
   
}
 
void loop()
{
  client.loop();
}
32  Using Arduino / LEDs and Multiplexing / Re: Buttons, interrupts and de-bouncing on: January 01, 2013, 05:33:36 am
Ok, more confused smiley-roll
I found this from Ladyada and she writes:
"To change the pins or number of buttons, just put them in the array called “buttons” and the rest of the code will automatically adjust."
http://www.adafruit.com/blog/2009/10/20/example-code-for-multi-button-checker-with-debouncing/
The second sketch uses interrupts. But she is using analog inputs and how can i just ad buttons if i can't just
use every input pin as interrupt??

This sketch also says: "which pin to use for reading the sensor? can use any pin!"
https://raw.github.com/adafruit/Adafruit-Flow-Meter/master/Adafruit_FlowMeter.pde
33  Using Arduino / LEDs and Multiplexing / Re: Buttons, interrupts and de-bouncing on: December 24, 2012, 05:38:18 am
I mean the person who writes the program...
So we need shirts now for the cool people with the print on them: I am a interrupter!
 smiley-lol
34  Using Arduino / Sensors / Re: Reading central heating system thermistor's? on: December 23, 2012, 07:15:59 pm
I just want to let you know that i already have some parts but not all and
that i also need to figure out some other stuff.
I will build it - not that you think your efforts on teaching me this was to no avail
35  Using Arduino / LEDs and Multiplexing / Re: Buttons, interrupts and de-bouncing on: December 23, 2012, 07:11:02 pm
Go where you feel the fun is (tm) smiley-grin
I better don't comment that *lol
36  Using Arduino / LEDs and Multiplexing / Re: Buttons, interrupts and de-bouncing on: December 23, 2012, 06:04:17 pm
Cool? Hm, i think nobody ever will ask: "hey how does this button work? do you use interrupts?"
If i build a egg timer for my 60 years old Mother. She never ever will look at the code or ask.
An Arduino for a egg timer *looool
But who knows. When Skynet comes alive and all machines communicate, maybe the egg timer is
in charge for the timing of the Terminator sorties smiley-grin

I just want to figure out whats the right way to do it. If you need to check the inputs
in the loops then the Atmega uses energy you maybe need for other stuff.
I always think that stuff needs to be build that it uses the least energy.
The other thing i read at Jeremy's (Blum) blog is:
Quote
Interrupts allow you run a program, while still being able to react to asynchronous input from the outside world.
So you can do stuff at the same time.
37  Using Arduino / LEDs and Multiplexing / Re: Buttons, interrupts and de-bouncing on: December 23, 2012, 03:12:36 pm
I will read i later. But just from overflying it i thought its just for the ATmega328p.

So does it make sense to always use interrupts for switching state instead of using
just digital IN and look at it all the time in a loop?
Please correct me if my logical thinking is not right smiley-neutral
38  Using Arduino / LEDs and Multiplexing / Re: Buttons, interrupts and de-bouncing on: December 23, 2012, 01:50:11 pm
You can buy a MEGA
I have two Mega but they also have just 6 interrupt pins.
Quote from: dhenry
It is useless only in the hands of useless programmers.
Sound like a sentences from somebody who was born and did
know programming and never had to start and learn.
39  Using Arduino / LEDs and Multiplexing / Buttons, interrupts and de-bouncing on: December 23, 2012, 09:44:19 am
Hi,

i just figured out that switching is not as easy as it seams.
Yes i recognized that sometimes the reaction on my buttons are poor - but i always
thought my buttons are cheap or i did not push enough smiley-lol

So now i was reading about de-bouncing and seams like that the Schmitt-Trigger solution is the
best choice. But when i was reading i stumbled over interrupts.
So attaching my buttons to the digital pins is not the best choice cause you need to
read the pins in a loop all the time to see if there is a change.

But there are just 2 interrupts on the Arduino?
So what to to if i want (for example) to switch 24 devices with 24 switches?

That also brings me to the question: every time i have something that only has a
low and high as input would better go to an interrupt (also if its maybe a optocoupler you read just to see on and off)?
But that would mean that "digitalRead INPUT" is useless?
40  Using Arduino / Project Guidance / Re: Automated greenhouse project on: December 21, 2012, 04:41:42 pm
For the sensors i really would look at the Dallas 1Wire stuff.
41  Using Arduino / Project Guidance / Re: Clean and energy efficient LED dimming on: December 21, 2012, 04:38:24 pm
Hm, didn't think of that before.
I already run CAT6 SFTP to all my wall switches.

Its AWG 23 so the table says 0,259 mm2 in German size.
And the other table from the VDE (in English = Association for Electrical, Electronic and Information Technologies e.V.)
says your allowed to run 4 ampere through 0,25 mm2.

So i can power 48 Watt of LED light. And i also can make it PoE and have Ethernet at the lamps if i need it one day.
Wow thats a nice idea and i was on my way to use AWG 16 or 13 because thats what you use for normal halogen stuff (3x 35 Watt/12 Volt halogen lamp = 8,75 ampere).
Thats the problem if you still think analogue today *lol


But the reason for this thread was more: how to dimm them.
Cause i need to order electronic parts and also want to order the FET's.

Edit:
My first test LED lamp is here.
There is something i forgot. They work with AC and DC and it doesn't matter
where you connect positive and negative. So there must be some kind of electronic inside the lamp.
Somebody know how they work? How does this effect the dimming circuit i need to build?
42  Using Arduino / General Electronics / Re: Tactile button maximum cable lenght? on: December 20, 2012, 09:31:18 pm
Or pulldown. But what do you mean by additional?

So 10-20 meters will not be a problem?
Maybe shielded cable?

I also have some water flow sensors here - here also I ask myself how long I can make
the cable.
43  Using Arduino / Project Guidance / Re: Clean and energy efficient LED dimming on: December 20, 2012, 08:25:30 pm
So just an IRL540 and everything is ok?

Also here in the forum i saw calculations for the right mosfet because off power wasting.

I don't buy one off this LED power supplies - i just take this Eco-Friendly 4 Ampere wall wart's

Edit:
What do you mean by untested lighting concept?
Something tried-and-true?

Everything here is 230 Volts. I don't want that anymore.
If i make it 12 Volt i save energy and can power it one day with photo voltaic.
44  Using Arduino / General Electronics / Tactile button maximum cable lenght? on: December 20, 2012, 08:13:23 pm
Hi,

what is the maximum cable length to connect a tactile button to the Arduino?
What cable would be the best (awg)?
45  Using Arduino / Project Guidance / Re: Clean and energy efficient LED dimming on: December 20, 2012, 07:59:26 pm
To much detail?
Hm, but nobody wants flickering lights in the living room?

Also the cables to my sleeping room ans bathroom will be around 10-20 meters.
In the moment everything is open - but when the wallpaper is done it's to late to change
something. So i need to make sure everything is planed correct and thats the reason
i read allot.

So what will be the best solution for my 12 Volt house lightning where everything can be dimmed?
Pages: 1 2 [3] 4 5 ... 7