|
Page 1 of 1
|
[ 6 posts ] |
|
| Author |
Message |
|
balu2012
Rookie
Joined: Thu May 17, 2012 3:35 pm Posts: 23
|
 Bluetooth startProgram
Hello Is it possible to start a Program from another NXT? I´ve connectet both NXT and its working. Im searching for a code like: RemoteStartProgram Please help me Thanks Now, I tried a little bit. - I´ve got another Problem! My Master send:  |  |  |  | Code: #pragma config(Sensor, S2, HTEOPD, sensorAnalogActive) #pragma config(Sensor, S4, touchSensor1, sensorTouch)
#include "drivers/HTEOPD-driver.h"
task main() { int x = 0; SetSensorType(S2, sensorLightActive); wait1Msec(100); SetSensorMode(S2, modeRaw); wait1Msec(100);
while(true) { eraseDisplay(); x = SensorRaw[S2]; nxtDisplayTextLine(0, "%4d", x); wait1Msec(100); if(SensorValue(HTEOPD) > 45) { PlaySound(soundBeepBeep); //Just for fun and testing wait1Msec(200); int my_number = 23;
sendMessage(my_number); } if (SensorValue(touchSensor1) == 1) { int my_number2 = 70; wait1Msec(3000); my_number2 = 70; sendMessage(my_number2); } } } |  |  |  |  |
The EOPD sends one Message to the Slave: 23, when the touchSensor is pressed the 17 and two motors should start.Slave:  |  |  |  | Code: #pragma config(Hubs, S1, HTMotor, HTServo, none, none) #pragma config(Motor, mtr_S1_C1_1, motorD, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C1_2, motorE, tmotorNormal, openLoop)
task DriveForward();
task DriveForward() { motor[motorD] = 65; motor[motorE] = 65; wait1Msec(1000); }
task main() { int my_message; int my_message2; while(true) { //Read the message to variable my_message = message; my_message2 = message; if(my_message != 0) //Let's say something got through if the signal is not zero { nxtDisplayTextLine(2,"1: %d",my_message); //Display the value as stored in the variable ClearMessage(); //Clear } wait1Msec(500); //Checking for a message every half a second is
if(my_message2 != 0) { StartTask(DriveForward); nxtDisplayTextLine(4,"2: %d",my_message2); //Display the value as stored in the variable ClearMessage(); //Clear } } } |  |  |  |  |
Question: The motors always run when the EOPD sends 23 or the touchSensor is 70. They don´t stop. Where is the mistake? Thanks
|
| Wed Aug 01, 2012 11:56 am |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2906 Location: Rotterdam, The Netherlands
|
 Re: Bluetooth startProgram
Hey there, You say your motors don't stop but where is the code to stop them?  - Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Thu Aug 02, 2012 12:40 am |
|
 |
|
balu2012
Rookie
Joined: Thu May 17, 2012 3:35 pm Posts: 23
|
 Re: Bluetooth startProgram
Sry. Like this? : . But my question is: The motors always run when the EOPD sends 23 or the touchSensor is 70. They only should run, if the message is 70. When the Slave gets the 23, another task should start (not in the code yet), but the motors start running.
|
| Thu Aug 02, 2012 3:50 am |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2906 Location: Rotterdam, The Netherlands
|
 Re: Bluetooth startProgram
What do you think will happen when this finishes: ? - Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Thu Aug 02, 2012 3:56 am |
|
 |
|
balu2012
Rookie
Joined: Thu May 17, 2012 3:35 pm Posts: 23
|
 Re: Bluetooth startProgram
ok. Like this? But how can I stop the message 70? when the tastSensor is pressed the master should send once 70 to start the program in slave
|
| Thu Aug 02, 2012 12:12 pm |
|
 |
|
balu2012
Rookie
Joined: Thu May 17, 2012 3:35 pm Posts: 23
|
 Re: Bluetooth startProgram
hello Thanks. Now its working. Question: I search for a "stop send message". is this possible? The robot should send only one message once: (I used wait1Msec for this.
|
| Fri Aug 03, 2012 11:57 am |
|
|
|
Page 1 of 1
|
[ 6 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 2 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|