Show Posts
|
|
Pages: [1] 2
|
|
1
|
Using Arduino / General Electronics / Re: Control other circuit with a transistor.
|
on: February 23, 2013, 04:40:57 pm
|
|
Thanks majenko, I'll check that out.
MarkT, do we understand each other correctly? The PD2 is in INPUT mode... I can't control anything with that pin...
The optocoupler is used to control the motor movement. If the switch is pressed, I want to light up the LED and stop the motor movement.
|
|
|
|
|
2
|
Using Arduino / General Electronics / Control other circuit with a transistor.
|
on: February 23, 2013, 04:00:54 pm
|
Hi guys, maybe a stupid question - please don't bite  I want to control the optocoupler circuit with a transistor, but there are few other things that messes the whole situation. If the switch is released: a) the LED should be turned OFF. b) the logical state on PD2 should be HIGH. c) the optocoupler should be connected with ground. How to achieve the third thing by not spoiling the other two? See attached schema.
|
|
|
|
|
5
|
Using Arduino / Networking, Protocols, and Devices / Re: Arduino with two uC. Problem with communication.
|
on: February 22, 2013, 11:18:53 am
|
|
I thought that it is the safest way to do that sort of things - one uC controling the motors, and the second one waiting for an error message sounds logical. I don't know how could I write a software for uC where I'm processing the loop (to move the stepper motor) and in the same time reading the incoming messages to RX pin.
An "emergency" situation occures when a limit switch is pressed by a platform, or simply when the user wants to stop the motors from Java app on his PC.
How can you perform while(Serial.available() > 1) {do sth} while doing this:
for(i=0; i<=y; i++){ // move x motor digitalWrite(6, HIGH); delay(timeout); digitalWrite(6, LOW); delay(timeout); }
?
|
|
|
|
|
6
|
Using Arduino / Networking, Protocols, and Devices / Arduino with two uC. Problem with communication.
|
on: February 22, 2013, 09:58:34 am
|
|
Hi guys, in my recent project I need to implement my own arduino, but instead of one Atmega I need two of them. The first one will be used to read some info from the FT232 chip and then move the stepper motors according to that info. But when the first uC controls the motors, the loops are in progress so it cannot read at the same time. Thats why i need a second one to eventually cut off the power from the first uC (ex. using a transistor) in a really "emergancy" situation.
Question: Can it be done? Can I connect two uC to RX and TX lines of FT232? If so, where to put pull up resistors? Can the value be the same as for one uC (1k)?
Please help.
|
|
|
|
|
10
|
Using Arduino / Networking, Protocols, and Devices / Re: Communication over a long distance using cable.
|
on: May 12, 2012, 11:27:27 am
|
|
Thanks guys. I came up with an idea, that I can send data in specified format, for example if the target of the data sent by the master is the device 1 than te data should look like
dev1:data
Then, some logic in the device 1 uC will divide this to "dev1", ":", "data", and check whether the first element equals "dev1" (this will be specified for every device). If so, the data will be used.
Will this solution work? If it will, will it be efficient? This will take several lines of code...
|
|
|
|
|
11
|
Using Arduino / Networking, Protocols, and Devices / Communication over a long distance using cable.
|
on: May 11, 2012, 06:03:24 pm
|
|
Guys, I need help. I want to connect several Arduinos with cable. There will be one master and several slaves. The distance between master and slave will be about 30 meters. I know that I can't use I2C, so I will use serial (RX & TX) and an RS485 communication (with MAX 485). Also, the slaves should read and write data to master, and master should read data from all slaves, and it should write data to every slave. The problem is that for example I want to send data to slave no. 2 but I don't want to send it to slave no. 3.
Is it possible to send data from the master to only one of several slaves? In I2C I could use an adress of the device, but I can't do this with RS485... Am I right?
How to solve that problem?
|
|
|
|
|
14
|
Using Arduino / Programming Questions / How to count seconds while the button is pressed?
|
on: May 06, 2012, 05:05:34 am
|
Hi, I'm having problem with reading the value "przycisk" (this means "button") while the inner loop starts... #include <LiquidCrystal.h>
int teraz = 0; // now int drzwi; // doors int przycisk; // button int i, j, k, l, m;
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
void setup() { lcd.begin(16, 2); pinMode(2, INPUT); pinMode(3, INPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); digitalWrite(5, LOW); digitalWrite(6, LOW); }
void loop() { if(teraz == 0) { przycisk = digitalRead(2); drzwi = digitalRead(3); if(drzwi == HIGH) { // the doors are open lcd.clear(); lcd.setCursor(0, 0); lcd.print("Drzwi otwarte."); // the doors are open lcd.setCursor(0, 1); lcd.print("Alarm rozbrojony"); // alarm disarmed digitalWrite(6, HIGH); // blink with green diode delay(500); digitalWrite(6, LOW); delay(500); while(przycisk == LOW) { // when somebody presses the button... for(i=0; i<=5; i++) { lcd.clear(); lcd.setCursor(0, 0); lcd.print("Uzbrajam..."); // arming the alarm lcd.setCursor(0, 1); lcd.print(i); digitalWrite(6, HIGH); // green diode ON delay(1000); if(i>=5) { for(j=30; j>=0; j--) { lcd.clear(); lcd.setCursor(0, 0); lcd.print("UZBROJONO!"); // ARMED lcd.setCursor(0, 1); lcd.print(j); delay(1000); if(j==0) { teraz = 1; przycisk = digitalRead(2); break; } } } } } } //rest of the code here...
The problem is with this part of code while(przycisk == LOW) because I want this loop to execute only WHILE the button is pressed. If the button is pressed for 5 sec then the alarm should arm. If the button is pressed for ex. 3 seconds, then it should go out from the loop and wait again... How to read the value "przycisk" inside this loop? for(i=0; i<=5; i++) {
|
|
|
|
|