Show Posts
Pages: [1] 2
1  Using Arduino / General Electronics / Re: Getting 5V D/C from single live wire A/C light switch on: April 17, 2013, 08:43:11 pm
Regarding getting the 5VDC from a wall switch. As has been already reported it is:
1 Dangerous if you do not know what you are doing, and
2 Typically a switch may not have a neutral wire available, and
3 Both the wires attached to the switch terminals are on only one leg of the AC.

It can be done, however, in certain circumstances with something similar to this diagram. This circuit will work by running a small amount of power through the light itself (caveat: this circuit was designed when all lights were incandescent, probably will not work with flourescents). The wall wart power module can be wired across the switch and as long as the switch is not turned on the power for the wall wart will be obtained through the light acting as a very low resistance inline resistor. The power consumption must be tailored to the needs of the wall wart without affecting the light.

This circuit was used in a film developing lab to prevent someone opening the door to a darkroom unless the inside light was on. Just do not install the two extra switches and instead of a transformer and bell use a wall wart DC adapter.

Again, if you are not sure, DO NOT DO IT.

2  Using Arduino / Installation & Troubleshooting / Re: Sketches moved from Windows to Ubuntu not recognized. on: April 15, 2013, 05:43:14 pm
SOLVED:
The problem is the way the IDE treats the sketchbook in Windows as opposed to Ubuntu.

In Windows I could add a sketch (folder containing .ino file) into my IDE folder and the sketch would show up in the Sketchbook.

In Ubuntu the IDE created a separate folder (not under the folder containing the IDE stuff) in the home directory. The IDE looked for sketches not in the sub folder of the IDE but in the separate folder it created. When I moved all the sketches to that folder they became available to the IDE.

Now all I have to do is make the IDE stop showing the "File Edit Sketch Tools Help" menu using black text on a black background.
3  Using Arduino / Installation & Troubleshooting / Re: Sketches moved from Windows to Ubuntu not recognized. on: April 15, 2013, 05:02:43 pm
Quote
Create a project with an unique name, save it, and search for that name.
In my original post I was trying to avoid cut & paste solution:
Quote
I am at a loss how to make the IDE recognize the files, other than opening each one in a new sketch and saving it. There must be a better way!
The sketch files are in the folder but the IDE does not recognize them. Why? It seems there must be a better way to get the IDE to recognize the sketches than by cut & paste.
4  Using Arduino / Installation & Troubleshooting / Sketches moved from Windows to Ubuntu not recognized. on: April 15, 2013, 03:36:25 pm
I am finally transitioning from Windows to Ubuntu. I foolishly thought I could just copy over all my sketches to the Ubuntu IDE folder in Ubuntu. However none of the copied files show up in the sketchbook. Since there is no folder named sketchbook I am at a loss how to make the IDE recognize the files, other than opening each one in a new sketch and saving it. There must be a better way!
The only thing I can think of, and I have no solution, is that in windows my IDE was in a folder with a different name than the one on Ubuntu. Does the IDE hard code path information and if so where is it and how can I change it?
I am going from Windows 2K to Ubuntu 12.04. The USB port in Windows stopped working for Serial.print() and rather than spend time trying to fix it again I am making the transition to Ubuntu.
Any help would be greatly appreciated.
5  Using Arduino / Programming Questions / Re: Error creating simple library file: IDE thinks constructor is a function on: March 26, 2013, 02:56:35 am
OK, I was right; I was doing something fundamentally wrong. All I did to make it compile was change the .cpp file in the library directory. I commented out this:
Code:
/*
#ifndef testRTC_h
#define testRTC_h
#endif
*/
And it compiled. Tomorrow I will test the compile and research the correct way to use those preprocessor directives. Right now it is bedtime. I do not know how to mark the thread as solved; maybe tomorrow.

Thanks to all who tried to help. If any of you know of a link to info on the preprocessor stuff I would thank you imensely.
6  Using Arduino / Programming Questions / Re: Error creating simple library file: IDE thinks constructor is a function on: March 26, 2013, 01:51:46 am
Clearly I am doing something fundamentally wrong but I do not know what!!
I made the following changes:
Code:
class testRTC     // Real Time Clock
  {
  public:
  testRTC(byte freqSQwave);                       // constructor
  testRTC();
  ...
  ...
In the .cpp file I added a constructor that needs no parameter:
Code:
//  ***************************************
testRTC::testRTC(byte freqSQwave = 0) {;}     // constructor with parameter
testRTC::testRTC() {;}                        // constructor with no parameter
//  ***************************************
in the sketch I made this change:
Code:
#include <Arduino.h>    // correct for 1.0.2
#include <testRTC.h>
#include <Wire.h>

testRTC rtc(0);

void setup() { Serial.begin(9600); delay(2000); }
void loop() { delay(2000); Serial.println("LOOP: "); }
Now I get multiple errors beginning:

C:\Arduino-IDE\libraries\testRTC\testRTC.cpp:11:
error: 'testRTC' has not been declared
C:\Arduino-IDE\libraries\testRTC\testRTC.cpp:11: error:
ISO C++ forbids declaration of 'testRTC' with no type
C:\Arduino-IDE\libraries\testRTC\testRTC.cpp:12: error:
'testRTC' is not a class or namespace
C:\Arduino-IDE\libraries\testRTC\testRTC.cpp:12: error:
ISO C++ forbids declaration of 'testRTC' with no type
C:\Arduino-IDE\libraries\testRTC\testRTC.cpp:14: error:
'testRTC' is not a class or namespace
C:\Arduino-IDE\libraries\testRTC\testRTC.cpp:
In function 'void setClock(byte*)':
C:\Arduino-IDE\libraries\testRTC\testRTC.cpp:17:
error: 'RTC_ADDRESS' was not declared in this scope
etc. etc. etc.

I do not know why but the IDE does not seem to be recognizing the .cpp file and maybe not the .h file.
HELP!
7  Using Arduino / Programming Questions / Re: Need help with basic code problem on: March 26, 2013, 01:31:45 am
First a suggestion: put a Serial.println(buttonCounter); in the loop. Then using the serial monitor you would quickly see that the counter is not being reset and after the first pass the switch value is beyond the possible case choices. This is because your counter is a global and is set outside of your loop, never to be reset in your code, after you increment it. You could move the counter into your loop and reset it each pass or leave it global and reset it each pass. As it is it unless you reset it the counter would have to go until it wrapped around before you would get another series of colors, a very long time. Serial.print is your friend.
8  Using Arduino / Programming Questions / Re: Error creating simple library file: IDE thinks constructor is a function on: March 26, 2013, 01:05:38 am
Pardon my density, I have only been programming C++ for a few weeks, but when you say "There is no mention there of a default argument." Where do you mean, in the sketch or in the class definition?  In the class definition I do have a parameter in the constructor and I tried putting one in the instantiation of the class with " testRTC rtc(0);" but I still get the errors. I tried "testRTC rte((byte) 0);" and still get errors. I added a constructor in the header file that does not require a parameter: " but still get errors. I took all code from the .cpp file and put it in the .h header file, commented out the code in the .cpp and compiled with NO errors. As far as I can tell what I have done is just like the tutorial but I get errors.

If someone could be more specific as to what is wrong it would help me a lot.

Yes I know the instantiation is calling a constructor but the IDE does not seem to recognize any of the code in my .cpp file which is in my library file with the header file.
9  Using Arduino / Programming Questions / Re: Error creating simple library file: IDE thinks constructor is a function on: March 26, 2013, 12:11:42 am
I am not sure what you mean when you say "there's no testRTC::testRTC(), there's only testRTC::testRTC(byte freqSQwave)". That is what the IDE says but I do not have a function call to testRTC(). That is what the IDE is looking for, and it is NOT in my code. The error message states "no matching function for call to 'testRTC::testRTC()'" but I do NOT have a function call, only a constructor. The error message calls it a function but a constructor is not a function so I do not know what the error message indicates the IDE wants.
P.S.
The code I distilled the aaa.ino from worked fine as long as the constructor, methods and functions remained in the header file, it was only when I tried to separate out the class, constructor and methods into a .h and .cpp file that I ran into the errors.
10  Using Arduino / Programming Questions / Error creating simple library file: IDE thinks constructor is a function on: March 25, 2013, 11:34:01 pm
I wrote and debugged a lot of code in a header file. I wanted to make it into a library so I followed the tutorial at: http://arduino.cc/en/Hacking/LibraryTutorial. I got a lot of errors so I decided to make an ultra simple library to familiarize myself with the problems. Unfortunately even the ultra simple code gave error messages like: error: no matching function for call to 'testRTC::testRTC()' where testRTC should have been my constructor, not a function call.
My sketch:
Code:
#include <Arduino.h>    // correct for 1.0.2
#include <testRTC.h>
#include <Wire.h>

testRTC rtc;

void setup() { Serial.begin(9600); delay(2000); }
void loop() { delay(2000); Serial.println("LOOP: "); }
my header file:
Code:
// test real time clock library
#ifndef testRTC_h
#define testRTC_h

#include <Arduino.h>
#include <Wire.h>

#define RTC_ADDRESS 0x68
#define ENABLE_SQ_WAVE_REG  0x07
#define ENABLE_SQ_WAVE      0x10   // default for 1 HZ output
// alternatives are: 0x10=1 HZ, 0x11=4 KHZ, 0x12=8 KHZ, 0x13=32 KHZ
//  ***************************************
class testRTC     // Real Time Clock
  {
  public:
  testRTC(byte freqSQwave);                       // constructor
  void setClock(byte *clockSetting);              // set clock with array
  void getClock(byte *clockSetting);              // put clock in array
  void enableSQwave(boolean enable, byte freq);   // enable/disable SQ wave
  protected:
  byte decToBcd(byte val);
  byte bcdToDec(byte val);
  };
#endif
The beginning of my .cpp file located in my library directory:
Code:
// Local real time clock
#ifndef testRTC_h
#define testRTC_h
#endif

#include <Arduino.h>
#include <Wire.h>
//#include "testRTC.h"   // for real time clock

//  ***************************************
testRTC::testRTC(byte freqSQwave = 0) {;}     // constructor
//  ***************************************
void testRTC::setClock(byte *clockSetting)    // points to setting
  {
  byte value;
  Wire.beginTransmission(RTC_ADDRESS);
  Wire.write( (byte) 0);                      // register pointer value
  for (int i = 0; i < 7; i++)                 // write the setting
    {
    value = clockSetting[6 - i];              // start with seconds value
    if (value == 255) break;
    Wire.write(decToBcd(value));              // convert as writing to RTC
    }
  Wire.write( (byte) 0);                      // may be to reset register pointer
  Wire.endTransmission();
  }
//  ***************************************
The full error message was:
aaa:5: error: no matching function for call to 'testRTC::testRTC()'
C:\Arduino-IDE\libraries\testRTC/testRTC.h:16:
note: candidates are: testRTC::testRTC(byte)
C:\Arduino-IDE\libraries\testRTC/testRTC.h:14:
note:                 testRTC::testRTC(const testRTC&)

In the sketch (aaa.ino) if I comment out "testRTC rtc;" it will compile but then there is no instance of the class I want to use. Seems as soon as the class is instantiated it tries to call a constructor and does not find the one I provided.

Any help would be greatly appreciated.

11  Using Arduino / Programming Questions / Re: Help needed: How to make a library from a .ino-file? on: February 20, 2013, 05:21:43 am
May I jump in here with a related question? I have been playing with a TM1638 LED display (8 characters 7 segments using I2C) and encountered the sendData function. I have searched the header files from the library, the .cpp files, even did a search of my whole Arduino directory for "*.* containing sendData". I have been unable to find the body of the function, where the actual code resides. The prototype is in the header files, the class is instantiated in the .cpp files but nowhere could I find the function. The code compiles and uploads and runs with no problems; I just can't find what exactly it is doing.  Since you seem to be dealing with the same function I hope you could point me to where I could study the function so I could understand what it is doing in more than a general sense like "is sends the data that has been readied."
Any help would be appreciated.
Thanks
12  Using Arduino / Installation & Troubleshooting / Re: Loopback anomalies continued on: February 06, 2013, 12:24:18 am
WOW! GREAT! A THOUSAND ATTABOYS (unless you are a girl in which case it is ATAGIRLS).

Went through the whole process of replacing usbser.sys, rebooted, plugged in my UNO and presto the serial monitor worked!

Make that two thousand ATTABOYS.

turbosnail
13  Using Arduino / Installation & Troubleshooting / Re: Loopback anomalies continued on: February 05, 2013, 07:09:45 pm
I have a 3.00 GHz CPU with 2 gigs ram with USB 2 and I regularly run external drives through my USB with no slowdown or problems. I even lowered the serial monitor baud to 4800 but loopback still fails. At 4800 if I send 80 characters only 5 are echoed. Higher baud rates return more characters, though not all are echoed, but only the first SEND will echo. The serial monitor has to be exited and reopened to get another echo. I could boot to an XP system but it is not yet setup to work with the IDE. The problem always comes back to how the IDE talks via the serial monitor to a board using the USB, I was hoping to use my time doing something with the UNO rather than using my time to make the IDE work. The photos below, from my original posting, demonstrate the failure.

14  Using Arduino / Installation & Troubleshooting / Loopback anomalies continued SOLVED on: February 05, 2013, 04:15:05 am
LOOPBACK FAILS.
I previously posted about failure using the loopback using serial monitor. My previous post was:
http://arduino.cc/forum/index.php?PHPSESSID=cd6e6ab20d71874ee1898ec6ceafb1b9&topic=143406.0
and the consensus was that the clone UNO-R3 was bad. I sent it back and bought a genuine UNO-R3 from Digi-Key. Same failure. So I tried the board on my laptop using Ubuntu 12.04 and the loopback on the board works fine. So it is NOT the hardware. The failing serial monitor is on a Windows 2000 system. I can make the IDE work by using my BoArduino and an FTDI connection but not with the UNO. I went into device manager and forced an update of the driver and pointed to "Arduino/drivers/Arduino UNO REV3.inf", which Windows seemed happy with. The FTDI and UNO-R3 have different COM ports but the one for the UNO still fails even though it is listed as for the R3.

QUESTION: Is there an incompatability between IDE 1.0.2, which I am using, and Windows 2K? I just can not make the loopback work on a UNO.

15  Using Arduino / Installation & Troubleshooting / Re: Loopback question on: February 01, 2013, 05:22:57 am
Let us consider this question answered.
To satisfy myself I used the only board I have, a BoArduino with an FTDI, with reset grounded and TX jumpered to RX. I created a 62 character string, a~zA~Z0~9, and stored it on the clipboard. I opened the IDE and opened the serial monitor and starting at the top of the board selections I sent the string using every board selection. As you all who have contributed to this posting would expect all echoes were identical. This is what I would have hoped for and expected. I knew that with the RX jumpered to the TX the AT328 on my board was bypassed. Had I done this first I would have never asked the question but since I had an anomaly with a UNO board (see the link above for the original posting) I did not know then what I know now. Since I did not know if there was a different communication protocol for different boards (which I would have thought poor planning) I asked the question here. In retrospect I should have tried my experiment first. Such is life!

To encapsulate my findings:
1.  All board types use the same communication protocol for the data stream. (not the same content to be uploaded or stored)
2.  With the standard loopback wiring it does not matter which board the Arduino IDE is set for. (it would matter for other tasks: uploading, programming etc.)

All of this is as I would have hoped, it was that I was just unsure.

Thanks to all who contributed.
Pages: [1] 2