need help to use values from serial monitor !

I need help to use the values received in the serial monitor to drive some pins either high/low

im using nrf24l0l modules on both sides with independent arduinos !

Tx is transferring data in the form of an array … like 0 0 0 0 0 0 0 0 0 0 0 0 123 123 123 123

i need to use these values to drive motors …
just let me know how this can be done

Thank You ! :slight_smile:

#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>
#define blue_led_pin 2
 
 
 
byte inBuffer[20];
 
byte rx_address[5] = {0xD0,0xD0,0xD0,0xD0,0xD0};
 
uint32_t lastCommandTime = 0;
 
uint8_t data;
 
void setup()
{
	pinMode(blue_led_pin, OUTPUT);
 
	Serial.begin(57600);
        Mirf.spi = &MirfHardwareSpi;
	Mirf.init();
	Mirf.setRADDR(rx_address);
	Mirf.payload = 20;
	Mirf.config();
}
 
void loop()
{
	if(!Mirf.isSending() && Mirf.dataReady())
	{
		Mirf.getData(inBuffer);
                data = ~inBuffer[2];
		Serial.print("-->\t"); 
                for(data = 0; data<20; data++)
                { 
                Serial.print(inBuffer[data]); 
                Serial.print(" "); 
                } 
                Serial.println();
		
		
 
		switch(data)
		{
			case 1:
				goForward();
				break;
			
		}
 
		Mirf.flushRx();
		lastCommandTime = millis();
	}
 
	
}
 
void goForward()
{
	digitalWrite(blue_led_pin, HIGH);
	
}

Hi,
Welcome to the forums.

Can you please post a copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

Thanks… Tom… :slight_smile:

Thank You Tom :slight_smile:

#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>
#define blue_led_pin 2
 
 
 
byte inBuffer[20];
 
byte rx_address[5] = {0xD0,0xD0,0xD0,0xD0,0xD0};
 
uint32_t lastCommandTime = 0;
 
uint8_t data;
 
void setup()
{
	pinMode(blue_led_pin, OUTPUT);
 
	Serial.begin(57600);
        Mirf.spi = &MirfHardwareSpi;
	Mirf.init();
	Mirf.setRADDR(rx_address);
	Mirf.payload = 20;
	Mirf.config();
}
 
void loop()
{
	if(!Mirf.isSending() && Mirf.dataReady())
	{
		Mirf.getData(inBuffer);
                data = ~inBuffer[2];
		Serial.print("-->\t"); 
                for(data = 0; data<20; data++)
                { 
                Serial.print(inBuffer[data]); 
                Serial.print(" "); 
                } 
                Serial.println();
		
		
 
		switch(data)
		{
			case 1:
				goForward();
				break;
			
		}
 
		Mirf.flushRx();
		lastCommandTime = millis();
	}
 
	
}
 
void goForward()
{
	digitalWrite(blue_led_pin, HIGH);
	
}

i need to use these values to drive motors ...

What sort of control over the motors do you need ?
Speed ?
Direction ?
Selection of which motor to control ?

How are the motors connected to the Arduino ?

I suggest you start with a completely separate program that controls your motor. That way the program will be simple and you can concentrate on the motor control issues.

When you get that working you should be able to graft the code onto your nRF24 program.

As @UKHeliBob says, we need to know about your motors before we can help.

...R

UKHeliBob:
What sort of control over the motors do you need ?
Speed ?
Direction ?
Selection of which motor to control ?

How are the motors connected to the Arduino ?

Well i can take care of the motors … im using a l298n motor driver … all i need is to use the received values … I just need to know how to use any of the value from all 20 to perform a logic …
That is the reason as of now im working with only one led to make things easier !

Thank You Bob ! :slight_smile:

Robin2:
I suggest you start with a completely separate program that controls your motor. That way the program will be simple and you can concentrate on the motor control issues.

When you get that working you should be able to graft the code onto your nRF24 program.

As @UKHeliBob says, we need to know about your motors before we can help.

...R

Thank You Robin ! :slight_smile:

i've replied to to the above post ... please refer !

n13geek:
i've replied to to the above post ... please refer !

OK. But you have not posted the motor code so I can't see how to relate it to your nRF24 code.

Presumably there is a variable in your motor code that represents the speed of the motor. If so, that variable probably needs to be updated by one of the values that is received by the nRF24.

...R