Show Posts
Pages: 1 ... 3 4 [5]
61  Using Arduino / Project Guidance / I2C and The Arduino Mega on: November 02, 2011, 06:24:51 pm
Hi all,
i have an example sketch for reading a CMPS10 compass using I2C from the wire library.
it states its using pins 4 & 5.
on the Mega i have 2 dedicated pins 20 and 21.
as far as i can tell the library is loaded on the AVR Ic already on the mega.
does that mean i can use the wire library and it will already be updated to run the mega on pins 20 and 21.
Cheers
J.
62  Using Arduino / LEDs and Multiplexing / Re: Switching multiple Leds on/off with value from PC on: November 02, 2011, 03:56:58 am
Hi CrossRoads,
The penny has dropped, i get what you were trying to tell me a couple of posts ago.
when i first saw it i thought is was back to bit banging, ie i pressed 1 and relay one operated, ie sending 1-8 to drive relay 1-8 (8 seperate commands).
Its quite obvious why you are a genius.
many thanks for your help i will give it another try.
Jason.
63  Using Arduino / Project Guidance / Re: Coordinate controlled XY Table - Hardware and software help on: November 01, 2011, 02:19:05 pm
Hi SnowWhite,

here is a link for a basic CNC milling machine from
http://www.milinst.co.uk/ goto the online shop and select the software and downloads tab
then sellect the files for 3 axis machine then press the download button at the bottom of the page.
you should be able to get some information from here for co-ordinates etc especially if you can get a copy of visual basic to open the source code files.
J.

Also Grumpy_Mike's CNC is bloody excellent, wow - that is a nice piece of engineering.

64  Using Arduino / LEDs and Multiplexing / Re: Switching multiple Leds on/off with value from PC on: November 01, 2011, 05:50:41 am
Hi Crossroads,
im just not getting it.
I have added the full 8 bit functions
and removed the mask %16
I have figured out that %2 represents Binary

OK my understanding of whats happening (being a VB programmer) with digitalWrite(ledPin3, (value >> 3) % 2);
if value is >4 then ledpin3 is written with the binary (%2 being either 1=higher 0=not higher).
I understand what you are saying about the input serial format being Ascii characters, unfortunately im at a loss as to how i can manitulate the data value to the correct format.  i have tried a few things like changing the variable format to Char and DEC etc, but not quite getting there.
i amd still suprised that an example of transmiting a grouped digital commandhas not made it onto the site yet, or the internet for that matter (ive looked long and hard, my eyes were all bloodshot last night and i just didnt need to dress up for halloween.

The code below works great up to 9 for some reason? - it is the 0 that appears to reset all o/p to zero but then again 16 dosnt display all outputs either.
* just tested again and the 1 of the 10 char is definitely where its falling over, is it because its a/the line feed chatacter?
but then why does it not effect the println echo.

Again you advice would be most valuable
thanks Jason

//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

int ledPin = 6;
int ledPin1 = 7;
int ledPin2 = 8;
int ledPin3 = 9;
int ledPin4 = 10;
int ledPin5 = 11;
int ledPin6 = 12;
int ledPin7 = 13;


int incomingByte; // for incoming serial data
 

void setup() {
  pinMode(ledPin, OUTPUT);  // initialize the LED pin as an output:
  pinMode(ledPin1, OUTPUT); // initialize the LED pin as an output:
  pinMode(ledPin2, OUTPUT); // initialize the LED pin as an output:
  pinMode(ledPin3, OUTPUT); // initialize the LED pin as an output:
  pinMode(ledPin4, OUTPUT); // initialize the LED pin as an output:
  pinMode(ledPin5, OUTPUT); // initialize the LED pin as an output:
  pinMode(ledPin6, OUTPUT); // initialize the LED pin as an output:
  pinMode(ledPin7, OUTPUT); // initialize the LED pin as an output:
 
  Serial.begin(9600);   
  Serial.println("Ready");
}

void loop() {
 // send data only when you receive data:
//if (Serial.available() > 0) {
    //incomingByte = Serial.read();
           
// only if there are bytes in the serial buffer execute the following code
  if(Serial.available()) {
    //inform that Arduino heard you saying something
    Serial.print("Arduino heard: ");
   
    //keep reading and printing from serial untill there are bytes in the serial buffer
     while (Serial.available()>0){
     incomingByte = Serial.read(); //read Serial
       Serial.print(incomingByte, BYTE); //prints the character just read
     }
     
    Serial.println();
   //Im seeing the value I send here,
  }
  //===================================================
  // the conversion below appears to be where its getting lost

int value = (incomingByte);// % 16; -works without this mask
  //Serial.println(value);
   digitalWrite(ledPin, (value >> 0 ) % 2);// LSB
   digitalWrite(ledPin1, (value >> 1) % 2);
   digitalWrite(ledPin2, (value >> 2) % 2);
   digitalWrite(ledPin3, (value >> 3) % 2);
   
   //digitalWrite(ledPin4, (value >> 4) % 2);
   //digitalWrite(ledPin5, (value >> 5) % 2);
   //digitalWrite(ledPin6, (value >> 6) % 2);
   //digitalWrite(ledPin7, (value >> 7) % 2); // MSB

}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
65  Using Arduino / LEDs and Multiplexing / Re: Switching multiple Leds on/off with value from PC on: October 31, 2011, 02:13:45 pm
Thanks Crossroads,
I will give it a try,
I found a similar code which is supposed to drive 4 leds but the serial input wont recognise values over 9
i found it on the web as a Ruby to Adruino code, i only wish i could remember where i found it...
if you can see anything blatantly obvious it would be appreciated

Cheers
Jason
==============================================================================================================
int ledPin = 10;
int ledPin1 = 11;
int ledPin2 = 12;
int ledPin3 = 13;
int incomingByte;// for incoming serial data
 

void setup() {
  pinMode(ledPin, OUTPUT);  // initialize the LED pin as an output:
  pinMode(ledPin1, OUTPUT); // initialize the LED pin as an output:
  pinMode(ledPin2, OUTPUT); // initialize the LED pin as an output:
  pinMode(ledPin3, OUTPUT); // initialize the LED pin as an output:
  Serial.begin(9600);   
  Serial.println("Ready");
}

void loop() {
 // send data only when you receive data:
//if (Serial.available() > 0) {
    //incomingByte = Serial.read();
           
// only if there are bytes in the serial buffer execute the following code
  if(Serial.available()) {
    //inform that Arduino heard you saying something
    Serial.print("Arduino heard you say: ");
   
    //keep reading and printing from serial untill there are bytes in the serial buffer
     while (Serial.available()>0){
        incomingByte = Serial.read(); //read Serial
        Serial.print(incomingByte, BYTE); //prints the character just read
     }

int value = (incomingByte) % 16;
  //Serial.println(value);
   digitalWrite(ledPin, (value >> 0 ) % 2);
   digitalWrite(ledPin1, (value >> 1) % 2);
   digitalWrite(ledPin2, (value >> 2) % 2);
   digitalWrite(ledPin3, (value >> 3) % 2); // MSB
}
}
=============================================================================================
66  Using Arduino / LEDs and Multiplexing / Switching multiple Leds on/off with value from PC on: October 31, 2011, 09:17:59 am
Im struggling to find a code example/sketch that will drive 8 digital outputs based on a value of 0~255 transmited from a PC to the Arduino Mega.
i would be greatful if someone could write a sketch that will do this for me.  i have searched the internet for days and have asked on the projects forum already, but have not succeeded in finding a solution.  There are lots of examples for just about everything apart from this.
many thanks in anticipation
J.
67  Using Arduino / Project Guidance / Re: DMX Relay on: October 30, 2011, 12:26:06 pm
Hi Kyle,
DMX is primarily a 3 wire system (all be it two and ground -RS485)
if you have the full complement of 5 wires ran to each location then in theory you could use the spare conductors/wires to switch the relay at the patch panel.
You would simply have to plug into a location to remotely take control of the system from there.
i would try putting a link between the spare unused pins, this link would then provide a link between a common connection and the routed relay at the patch panel.  the relay would then link the DMX data line from the desk to the system.
OR use an Arduino to do the logical part, but you will still end up needing a relay/physical switch to route the DMX communication lines
68  Using Arduino / Project Guidance / Re: MEGA 2560 Help wanted with coding on: October 28, 2011, 03:23:07 am
Hi evryone,
still not found help

Can you please advise how i might send a byte of data via the usb to the mega
(received from a pc)
which will drive 8 digital outputs.

As I also intend sending another stream of data, is it possible to add an identifier to the data so that the mega knows where to direct the data ie write digital out data to a variable ready to be used.

I plan to use the same port to transmit serial data for dmx output to the mega hence the requirement for an identifier.

Regards
Jason
69  Using Arduino / Project Guidance / Re: Cutting rectangles in plastic enclosures; which tools to diy? on: October 27, 2011, 01:42:49 pm
Hi ericneilj,
this is what’s on offer all be it my old one http://www.milinst.co.uk/       - 3 axis machine, goto their store it has a better description in there
I also have a 3 axis sampling rig out of a laboratory which i got off ebay.  I was planning to build a PCB milling machine, but etching is so much easier these days especially when you use caustic soda instead of developer.
if you feel you can find reasonable postage costs then get back to me.
One day i will get sick of the sight of them and they will end up in landfill.
Jason.
70  Using Arduino / Project Guidance / Re: MEGA 2560 Help wanted with coding on: October 27, 2011, 12:00:42 pm
Hi all,
thanks for replying.
I want to use my adruino mega to interface with a robot of sorts.
I have a VB.net application already which will use the usb link to the arduino to send and receive data.
I need to send 8 switch values (digital output), read 8 analogue instrument values and i would like to use DMX to produce 8 x analogue outputs (I only need the DMX bridge to transmit from the adruino the other hardware is already in place.
if i use the USB port as communication for the pc to the arduino to transmit and receive data, i will need a method of telling the arduino to produce a DMX command or drive a digital output.  I admit receiving the analogue inputs will be quite straight forward.
The arduino co-founders blog on the DMX code is flagging up an error- one of the statements is not declared (digital pin, somthing or other) if any one has knowledge of any issues or a working sketch it would be much appreciated.
I had a good laugh at Frasier Kranes comments (PaulS) you are a star - i guess i deserved it.

I discovered another member asked a similar question about pin mapping, when your confronted with a new piece of technology it hard to get your head around what the manufacturers are trying to convey if they dont actually make a statement anywhere which spells it out. maybees im just being perdantic.

Anyways - is there a way i can send a character/or data from the PC which will be transposed into a block of digital outputs ie. a byte becomes the on/off condition for a block of switches.  As im going to be sending digital output commands, DMX and reading analogue inputs i would like to get the number of communication commands down to a minimum.  Bit banging would use a huge number of commands per second for the USB port to handle.

also how could i block read the analogue inputs to receive a data stream instead of individually receiving them as in the example.

Best regards
Jason
71  Using Arduino / Project Guidance / Re: Cutting rectangles in plastic enclosures; which tools to diy? on: October 27, 2011, 03:57:23 am
Hi ericneilj,
where are you based, which country.
If you are in the UK i may have a few old cnc projects lying around which may be of interest.
you could then use an Arduino to control them.
Regards
Jason
72  Using Arduino / Project Guidance / MEGA 2560 Help wanted with coding on: October 27, 2011, 03:38:01 am
I am currently working my way through the examples but cant seem to find a particular way of sending data from a PC to the Adrunio which will switch on 8 digital outputs.  I would like to be able to send instruction as a Byte from the PC with some sort of identification attached which would be stripped from the data before being transmitted.  Ideally I want the unit to serve my project using multiple comm send and receives for data aquisition.
reading through some examples i have found that i can read the analogue inputs, send digital outputs and perhaps have DMX output aswell.
the DMX would be used to send instructions to an 8CH led dimmer circuit (Hendrik's DMX Dimmer) to provide analogue outputs.
any help in this direction would be greatfully appreciated.

Also i keep reading that i cant use pins 4 & 5 as they are dedicated to Serial Comms.  Im using the Mega is this still true as i have more than enough pin and I have other magic pins labled 0 & 1 for serial comms.
"can i use thes instead until i find the other ones lol"
incidently the pin map starts at pin 1 not 0 WHY!, the functions dont even coincide as pin 1 is a PWM pin?
very confused, please advise.
and no not the famous Microsoft suggestion - Put it back in the box and return it-your to stupid to own a computer.
regards
Jason
Pages: 1 ... 3 4 [5]