Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Transmit sensor data wirlessly using VirtualWire libary .... need help on: May 22, 2013, 07:18:09 am
I'm working a project for uni in which i have to tramsit telementry data (like temp) from a transmitter to a reciever, i understand the basics of using the VirtualWire libary to send hard coded piece of data, what i don't know how to do is to transmit data from a sensor that's on the arduino board:

the generic trasmitter code i have is this:

Code:
#include <VirtualWire.h>

const int led_pin = 11;
const int transmit_pin = 12; //Pins will need to be changed
const int receive_pin = 2; //Pins will need to be changed
const int transmit_en_pin = 3; //Pins will need to be changed

void setup()
{
  // Initialise the IO and ISR
  vw_set_tx_pin(transmit_pin);
  vw_set_rx_pin(receive_pin);
  vw_set_ptt_pin(transmit_en_pin);
  vw_set_ptt_inverted(true); // Required for DR3100
  vw_setup(2000); // Bits per sec
}

byte count = 1;

void loop()
{
  char msg[7] = {'h','e','l','l','o',' ','#'};

  // WANT TO BE ABLE TO SEND SENSOR DATA HERE RATHER THAN HARD CODED BITS OF DATA

  msg[6] = count;
  digitalWrite(led_pin, HIGH); // Flash a light to show transmitting
  vw_send((uint8_t *)msg, 7);
  vw_wait_tx(); // Wait until the whole message is gone
  digitalWrite(led_pin, LOW);
  delay(1000);
  count = count + 1;
}

If you can post some hints in terms of saying some basic lines of code that would be great

I've already tried to do this project once, and didn't understand it very well so, if the explanations could be as if your talking to a complete newbie when working with the virtualwire and intergrating things that would eb great
2  Using Arduino / Programming Questions / Re: Use a POT to control a time limit on: November 13, 2012, 04:59:48 pm
How do you normally divide something?
by using " / "
3  Using Arduino / Programming Questions / Re: Use a POT to control a time limit on: November 13, 2012, 04:56:50 pm
Quote
i've used "analogeRead" but doesn't work
And that means what exactly?
(The compiler expects you to spell it correctly, if that's what you meant)

Scaling usually involves an arithmetic function.
using the "analogeRead()" read in the pot value, but i don't know what to devid the value by to get the scale right
4  Using Arduino / Programming Questions / Re: Use a POT to control a time limit on: November 13, 2012, 04:46:40 pm
Read the POT using analog in. Write or scale that value into the variable you use in your time delay loop.

No need for interrupts  or other complex processing. Every time through loop read the POT and update the variable with the delay time.
no idea how to scale that value, i've used "analogeRead" but doesn't work
5  Using Arduino / Programming Questions / Re: Use a POT to control a time limit on: November 12, 2012, 09:20:04 am
The analogRead will return a value in the range 0 .. 1023.
If this isn't a convenient range of values, you could use the "map" function to get it to more convenient units, or, as you did in your LED dimmer, just use simple arithmetic.

Plug the resulting value into the "interval" variable in blink-without-delay.
that's what i ended up doing but not sure if it works (as i have no cable can't tell if it's working) and i don't wanna use interputs in my programme just yet
6  Using Arduino / Programming Questions / Use a POT to control a time limit on: November 12, 2012, 08:57:50 am
I wanna use a POT to control the time of a certain function and for the life of me i can't work out how to get the POT to control the time could someone try to explain it to me (no code if you can help it)

Note; already read the "BlinkWithoutDelay" just wanna adapt it slightly
7  Using Arduino / Programming Questions / Re: Using a Pot to control the brightness of a LED on: November 12, 2012, 05:32:24 am
Quote
one leg of the pot goes to +5, the other to Gnd, the wiper to the ADC pin?
I thought for sure you'd know that.
i'm using a Arduino board all of the wiring has already been done, even if it hadn't done electronics for 4 years so woulda doen that first smiley-razz

All the wiring is done, you posted an (apparently) working piece of code...what exactly was the problem?

beacuse i thought i left something out, as i was thinking there was no way the programme could be that easy (turns out it could be)
8  Using Arduino / Programming Questions / Re: Using a Pot to control the brightness of a LED on: November 11, 2012, 06:34:16 am
Quote
one leg of the pot goes to +5, the other to Gnd, the wiper to the ADC pin?
I thought for sure you'd know that.
i'm using a Arduino board all of the wiring has already been done, even if it hadn't done electronics for 4 years so woulda doen that first smiley-razz
9  Using Arduino / Programming Questions / Re: Using a Pot to control the brightness of a LED on: November 10, 2012, 06:25:12 pm
Quote
ok, now i forget how to do that, thats what i get for doing this late at night 
It's the only executable line in the code you posted.
oh derp, so if i wanted to control more LEDs using another POT would it be the same kinda code?
10  Using Arduino / Programming Questions / Re: Using a Pot to control the brightness of a LED on: November 10, 2012, 06:11:33 pm
Adc a pin and then use it to control the duty cycle of the pin that is driving your led.

ok, now i forget how to do that, thats what i get for doing this late at night smiley
11  Using Arduino / Programming Questions / Re: Using a Pot to control the brightness of a LED on: November 10, 2012, 05:35:00 pm
Does your code work?
I can't see a problem, but maybe you've wired it wrong.
For extra points, you may want to use those nice names you've given the pins.
unfortunaley i don't have a cable with me so i can't check it, to me something seems missing
12  Using Arduino / Programming Questions / Using a Pot to control the brightness of a LED on: November 10, 2012, 05:18:28 pm
at uni we were set a task about how to control the brightness of a LED using a POT now although i'm sure i know howto do it, i've got a bt of a memory blank;

this is the code i have so far;

#define POT1 0
#define POT2 1
#define LED1 5
#define LED2 6

void setup()
{
 
}

void loop()
{
  analogWrite(5, analogRead(0)/4);
}

what do i need, please don't give me excat code (not gonna learn that way) just tell what i need to do, eg (you to initalise something)
Pages: [1]