Using Arduino Nano for stepper control AND temp sensor with LCD

Hi all

I was wondering if someone can help. I have an Arduino Nano which I'm using with a joystick module to control a stepper motor as part of a remote focuser for a telescope (see this thread: http://forum.arduino.cc/index.php?topic=435888.0;nowap)

I also want to add a temperature/humidity sensor with lcd readout to the main project box.

Question is - will I need a separate arduino Uno for the temp sensor, or can I use the same one I'm using for the stepper control at the same time?

If so, any ideas on how to add to the current sketch for the stepper motor control in the above post (as a new sketch just for the temp sensor would overwrite the stepper sketch)?

Any help greatly appreciated - thanks. :slight_smile:

You should be able to do everrything with one Arduino. You are correct, if you create a new sketch and upload it, it will overwrite the existing sketch.

You have to take the two sketches and merge them into one. Take whatever specific Setup is being done in sketch two and add it to sketch one. Add whatever processing is being done in sketch two to sketch one. Etc.

If that works for you, congratulations. If it doesn't work then post the original sketches and your merged one here. Most of the helpers here are more eager to help someone who they perceive to be trying to help themselves.

Thanks JaBa. Im waiting on delivery of the temp sensor so once I have that, I'll test and let you no.

Can the new sketch details go outside of the current stepper sketch - e.g. at the bottom, after the stepper code?

Never merged 2 sketches so just wondering about the format.

A couple of pages on merging code

http://www.thebox.myzen.co.uk/Tutorial/Merging_Code.html

https://arduino-info.wikispaces.com/CombiningArduinoSketches

Great - thanks GF. Just what I needed :slight_smile:

When dealing with stepper motors and "simultaneously" reading a sensor you will have to make sure that both actions (sending steps to the stepper and reading the sensor) are using non blocking code. So avoid all delay(), while.. and other blocking commands.

Whenever you need some kind of delays or timers have a look at the blink without delay example which comes with the IDE.

These links may be of interest.
Stepper Motor Basics
Simple Stepper Code

...R