Show Posts
|
|
Pages: [1]
|
|
1
|
Using Arduino / General Electronics / Re: LED on when relay off?
|
on: August 18, 2012, 10:35:14 am
|
Thanks! I'm not sure if I did it how you described but got it working. The switch has C, NO (normally open) and NC (normally closed) marks on the contacts and I suppose they are the same IN, OUT and GND, that made me confused. I feel stupid  Here's how it's now 
|
|
|
|
|
2
|
Using Arduino / General Electronics / LED on when relay off? //solved
|
on: August 18, 2012, 04:26:34 am
|
|
Hi!
Is it possible to get LED on when relay is off with NPN transistor and how would you do it? I'm thinking way too simplified right now and can't figure it out..
This is for a switch which has a built in LED that I want to be light when the switch is off..
|
|
|
|
|
3
|
Using Arduino / Programming Questions / Re: Merging two codes, reading from ultrasonic sensor to display
|
on: March 01, 2011, 09:39:19 am
|
Hi, I have now tested the code and it works, but it needs some tweaks. When the distance increases the displays starts to flicker. I believe it's because it takes longer time to get the distance by the sensor. How can I make the display code to be primary code and the measurement code to be secondary so it is not done with same frequency? #include "URMSerial.h" #define DISTANCE 1
int ledPin = 13; URMSerial urm;
// Arduino pins connected to the 4511 const int LedA = 4; const int LedB = 5; const int LedC = 6; const int LedD = 7;
// Arduino pins connected to the segment driver transistors const int D1 = 8; const int D2 = 9; const int D3 = 10;
void setup() {
Serial.begin(9600); // Sets the baud rate to 9600 urm.begin(2,3,9600); // RX Pin, TX Pin, Baud Rate pinMode(ledPin, OUTPUT);
// Let the Arduino know which pins go where pinMode(LedA, OUTPUT); pinMode(LedB, OUTPUT); pinMode(LedC, OUTPUT); pinMode(LedD, OUTPUT); pinMode(D1, OUTPUT); pinMode(D2, OUTPUT); pinMode(D3, OUTPUT); digitalWrite(D1, LOW); digitalWrite(D2, LOW); digitalWrite(D3, LOW); }
void loop() { // Request a distance reading from the URM37 urm.requestMeasurement(DISTANCE);
// Avoid fetching the distance until we're sure the reading is ready if(urm.hasReading()) { int value; // This value will be populated switch(urm.getMeasurement(value)) // Find out the type of request { case DISTANCE: // Double check the reading we recieve is of DISTANCE type Serial.println(value);
// Display the first digit Display(value / 100); // Send first digit to the 4511 value = value % 100; // Calculate next digit digitalWrite(D1, HIGH); // Illuminate first segment delay(2); // Wait digitalWrite(D1, LOW); // Extinguish first segment
// Display the second digit Display(value / 10); value = value % 10; digitalWrite(D2, HIGH); delay(2); digitalWrite(D2, LOW);
// Display the third digit
Display(value); digitalWrite(D3, HIGH); delay(2); digitalWrite(D3, LOW);
break; } } }
void Display(int n) { if ( n > 9 ) { n = 9; }
if ( n < 0 ) { n = 0; }
if ( n / 8 == 1 ) { digitalWrite(LedD, HIGH); } else { digitalWrite(LedD, LOW); }
n = n % 8;
if ( n / 4 == 1 ) { digitalWrite(LedC, HIGH); } else { digitalWrite(LedC, LOW); } n = n % 4;
if ( n / 2 == 1 ) { digitalWrite(LedB, HIGH); } else { digitalWrite(LedB, LOW); } n = n % 2;
if ( n == 1 ) { digitalWrite(LedA, HIGH); } else { digitalWrite(LedA, LOW); } }
|
|
|
|
|
7
|
Using Arduino / Programming Questions / Re: Merging two codes, reading from ultrasonic sensor to display
|
on: February 14, 2011, 05:18:17 pm
|
I am sorry but I can't figure out how to do that.  Here's what I manage to cobble together. #include "URMSerial.h" #define DISTANCE 1
int ledPin = 13; URMSerial urm; int output = 0;
// Arduino pins connected to the 4511 const int LedA = 5; const int LedB = 8; const int LedC = 7; const int LedD = 6;
// Arduino pins connected to the segment driver transistors const int Led1 = 4; const int Led2 = 3; const int Led3 = 2;
void setup() {
Serial.begin(9600); // Sets the baud rate to 9600 urm.begin(9,10,9600); // RX Pin, TX Pin, Baud Rate pinMode(ledPin, OUTPUT);
// Let the Arduino know which pins go where pinMode(LedA, OUTPUT); pinMode(LedB, OUTPUT); pinMode(LedC, OUTPUT); pinMode(LedD, OUTPUT); pinMode(Led1, OUTPUT); pinMode(Led2, OUTPUT); pinMode(Led3, OUTPUT); digitalWrite(Led1, HIGH); digitalWrite(Led2, HIGH); digitalWrite(Led3, HIGH); }
void loop() { // Request a distance reading from the URM37 urm.requestMeasurement(DISTANCE); // You may call this as many times as you like. It will only send once
// Avoid fetching the distance until we're sure the reading is ready if(urm.hasReading()) { int value; // This value will be populated switch(urm.getMeasurement(value)) // Find out the type of request { case DISTANCE: // Double check the reading we recieve is of DISTANCE type
// Display the first digit Display(value / 100); // Send first digit to the 4511 output = value % 100; // Calculate next digit digitalWrite(Led1, LOW); // Illuminate first segment delay(2); // Wait digitalWrite(Led1, HIGH); // Extinguish first segment
// Display the second digit Display(value /10); output = value % 10; digitalWrite(Led2, LOW); delay(2); digitalWrite(Led2, HIGH);
// Display the third digit Display(value); output = value; digitalWrite(Led3, LOW); delay(2); digitalWrite(Led3, HIGH);
delay(200); break; } } }
|
|
|
|
|
8
|
Using Arduino / Programming Questions / Re: Merging two codes, reading from ultrasonic sensor to display
|
on: February 14, 2011, 04:21:10 pm
|
I do realise that and think it should be taken into the account some how in the code. Dose this look anything like you thought?  #include "URMSerial.h"
#define DISTANCE 1 #define TEMPERATURE 2 #define ERROR 3 #define NOTREADY 4
int ledPin = 13; URMSerial urm; int output = 0;
// Arduino pins connected to the 4511 const int LedA = 5; const int LedB = 8; const int LedC = 7; const int LedD = 6;
// Arduino pins connected to the segment driver transistors const int Led1 = 4; const int Led2 = 3; const int Led3 = 2;
void setup() {
Serial.begin(9600); // Sets the baud rate to 9600 urm.begin(9,10,9600); // RX Pin, TX Pin, Baud Rate pinMode(ledPin, OUTPUT);
// Let the Arduino know which pins go where pinMode(LedA, OUTPUT); pinMode(LedB, OUTPUT); pinMode(LedC, OUTPUT); pinMode(LedD, OUTPUT); pinMode(Led1, OUTPUT); pinMode(Led2, OUTPUT); pinMode(Led3, OUTPUT); digitalWrite(Led1, HIGH); digitalWrite(Led2, HIGH); digitalWrite(Led3, HIGH); }
void loop() { // Request a distance reading from the URM37 urm.requestMeasurement(DISTANCE); // You may call this as many times as you like. It will only send once
// Avoid fetching the distance until we're sure the reading is ready if(urm.hasReading()) { int value; // This value will be populated switch(urm.getMeasurement(value)) // Find out the type of request { case DISTANCE: // Double check the reading we recieve is of DISTANCE type
digitalWrite(Led1, LOW); // Illuminate first segment delay(2); // Wait digitalWrite(Led1, HIGH); // Extinguish first segment
// Display the second digit Display(output / 10); output = output % 10; digitalWrite(Led2, LOW); delay(2); digitalWrite(Led2, HIGH);
// Display the third digit Display(output); digitalWrite(Led3, LOW); delay(2); digitalWrite(Led3, HIGH);
delay(200); break; } } }
|
|
|
|
|
9
|
Using Arduino / Programming Questions / Merging two codes, reading from ultrasonic sensor to display
|
on: February 14, 2011, 03:27:46 pm
|
Hi, I have been working on ultrasonic distance meter with display and got the distance out of the sensor with this code #include "URMSerial.h"
#define DISTANCE 1 #define TEMPERATURE 2 #define ERROR 3 #define NOTREADY 4
int ledPin = 13; URMSerial urm;
void setup() {
Serial.begin(9600); // Sets the baud rate to 9600 urm.begin(2,3,9600); // RX Pin, TX Pin, Baud Rate pinMode(ledPin, OUTPUT); }
void loop() { // Request a distance reading from the URM37 urm.requestMeasurement(DISTANCE); // You may call this as many times as you like. It will only send once
// Avoid fetching the distance until we're sure the reading is ready if(urm.hasReading()) { int value; // This value will be populated switch(urm.getMeasurement(value)) // Find out the type of request { case DISTANCE: // Double check the reading we recieve is of DISTANCE type Serial.println(value, DEC); // Fetch the distance in centimeters from the URM37
delay(200); break; } } }
I would like to merge it to this, but since I am not compleatly sure what parts of the code are nessessary it's quite dificult. If you show me what parts are nessasary I would like to try merge them myself. // Arduino pins connected to the 4511 const int LedA = 5; const int LedB = 8; const int LedC = 7; const int LedD = 6;
// Arduino pins connected to the segment driver transistors const int Led1 = 4; const int Led2 = 3; const int Led3 = 2;
long count = 0; int output = 0; int remain = 0;
void setup() { // Let the Arduino know which pins go where pinMode(LedA, OUTPUT); pinMode(LedB, OUTPUT); pinMode(LedC, OUTPUT); pinMode(LedD, OUTPUT); pinMode(Led1, OUTPUT); pinMode(Led2, OUTPUT); pinMode(Led3, OUTPUT); digitalWrite(Led1, HIGH); digitalWrite(Led2, HIGH); digitalWrite(Led3, HIGH); }
void loop() { // The counter runs from 0-9999 so divide this by 10 as // we only have three display segments output = count / 10;
// Display the first digit // The order of these steps is important to prevent // visible 'bleeding' on the display Display(output / 100); // Send first digit to the 4511 output = output % 100; // Calculate next digit digitalWrite(Led1, LOW); // Illuminate first segment delay(2); // Wait digitalWrite(Led1, HIGH); // Extinguish first segment
// Display the second digit Display(output / 10); output = output % 10; digitalWrite(Led2, LOW); delay(2); digitalWrite(Led2, HIGH);
// Display the third digit Display(output); digitalWrite(Led3, LOW); delay(2); digitalWrite(Led3, HIGH);
// Count to 9999 then reset count = count + 1; if (count > 9999) { count = 0; } }
// Function to display the digit 'n' void Display(int n) { if ( n > 9 ) { n = 9; }
if ( n < 0 ) { n = 0; }
if ( n / 8 == 1 ) { digitalWrite(LedD, HIGH); } else { digitalWrite(LedD, LOW); }
n = n % 8;
if ( n / 4 == 1 ) { digitalWrite(LedC, HIGH); } else { digitalWrite(LedC, LOW); } n = n % 4;
if ( n / 2 == 1 ) { digitalWrite(LedB, HIGH); } else { digitalWrite(LedB, LOW); } n = n % 2;
if ( n == 1 ) { digitalWrite(LedA, HIGH); } else { digitalWrite(LedA, LOW); }
}
|
|
|
|
|
10
|
Using Arduino / Project Guidance / Re: Ultrasonic distance meter with display
|
on: February 14, 2011, 02:59:06 pm
|
I have now followed two pages for this project, this to get the untrasonic work and this for controlling the 3 digit 7 segment display. I have manage to get the distance out of the sensor. The displays havn't arrived yet so I havn't been able to figure out how to get them show the value from the sensor. But meanwhile waiting for the displays to arrive I have designed a custom shield. All the components should fit between the Arduino and the shield. It needs some tweaking but I think I have done quite well since this is my first design. I tried to design it so it would be easy so solder at home. If you now how it could be improved, please tell  And for the guidance, I would appreciate help with the code. I tought it would be good to make a topic under the code section, it's here
|
|
|
|
|
12
|
Using Arduino / Project Guidance / Re: Ultrasonic distance meter with display
|
on: January 26, 2011, 03:14:33 pm
|
To understand why I demand something from this device I shall tell you where it's going to be used. I'm doing this for my parents, their carage is partially quite tight. The meter is not necassary but I tought it would be fun to make one so here I am Onions, I would like to use an LCD display but the numbers should be quite big and bright and I couldn't find any. Or I didn't know where to search. Now they are planned to be 3" (7,62 cm) high. And now the number of seven segment displays is increased to 3 because of my fathers request. Now I'm wondering how I'm going to connect those to the Arduino, I will check the forum and the tutorials pages if there's anything for me. pmodernme, thats a good idea, thanks! The reason why, is that the carage door is opened by an electrical motor, and when it's used a lamp is turned on and stays on for a while. I tought that my device could be powered at the same time as the lamp is. Thanks for your input, I'm getting excited 
|
|
|
|
|
14
|
Using Arduino / Project Guidance / Ultrasonic distance meter with display
|
on: January 26, 2011, 09:32:03 am
|
Hi, I'm going to make an ultrasonic distance meter with display. It should be quite simple and good for a beginner I guess. For my idea the device should consist of these components: - URM37 V3.2 ultrasonic sensor
- 2x seven segment displays
- Arduino
Which Arduino board is enough for this project? I'm thinking of Mini or Nano.
|
|
|
|
|