A INTERFACE OF SENDING AND RECIVING DATA

so this is my project i have a scanner it will scan barcodes then it will send data to arduino then that will activate A electromagnet and helps in rotating some mechanism then the proxmity sensor comes in contact after a round of roatation it sends signal and deactivates the electromagnet and this should be going every time i scan the barcode and the power needed by these all electromagnet and sensor uses 24 v power and signal is even 24v even i want to convert the 24v signal to 5v signal

Please edit your post to use lower case characters in the text and title.

Hi Welcome to the forum.

Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html

so this is my project

i have a scanner, it will scan barcodes then it will send data to arduino then that will activate A electromagnet

and helps in rotating some mechanism then the proxmity sensor comes in contact after a round of roatation it sends signal and deactivates the electromagnet

and this should be going every time i scan the barcode

the power needed by these all electromagnet and sensor uses 24 v power

the signal is even 24v i want to convert the 24v signal to 5v signal

Sorry, but had to edit it to point form to see what you have.

You may be better off drawing and posting a diagram of the mechanism you are talking about.

Can you tell us your electronics, programming, Arduino, hardware experience?

Tom... :)

I AM JUST LIKE BEGGINER I DONT HAVE THE PICTURE RIGHT NOW BUT ICAN SAY THAT WHEN YOU SCAN THE BARCODE THERE IS A ELECTROMAGNET COIL WHICH SHOULD ACTIVATED AND WHEN A METAL OBJECT IS JUST BROUGHT IN FRONT OF THE SENSOR IT WILL JUST TURN OFF THE ELECTROMAGNET AND I WANT THIS IN A LOOP

Stop shouting and find out where your full stop key is. If you can not find it then you will not be smart enough to make your project.

Hi,

I AM JUST LIKE BEGGINER I am just like a begginer

We gathered that. But for us to help you, you need to know some basic rules of the forum.

Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html

It will make it easier for us to give you any solutions to the problems you have with your project.

I DONT HAVE THE PICTURE RIGHT NOW I don't have the picture right now

Fair enough, you can't be everywhere.

BUT ICAN SAY THAT WHEN YOU SCAN THE BARCODE THERE IS A ELECTROMAGNET COIL WHICH SHOULD ACTIVATED But I can say that when you scan the barcode there is a electromagnet coil which should activated

So a barcode scanner, what type, part number, spec? When an object is in scanning range the scanner activates an electromagnet What are the specs of the solenoid? or do you mean a relay or contactor? Does this electromagnet start the object rotating?

AND WHEN A METAL OBJECT IS JUST BROUGHT IN FRONT OF THE SENSOR IT WILL JUST TURN OFF THE ELECTROMAGNET And when a metal object is just bought in front of the sensor it will just turn off the electromagnet.

So you have another sensor that detects the metal object that is now being rotated and when it is activated the electromagnet is deactivated and the object stops rotating. OR Do you rotate the object till the barcode reappears in the scanner and when it is activated the electromagnet is deactivated and the object stops rotating.

I WANT THIS IN A LOOP I want this to loop

Then you want the system to wait until another object is detected by the barcode reader.

Are you just a beginner with Arduino, or electronics and mechanics in general? Can you tell us your electronics, programming, Arduino, hardware experience?

Thanks.. Tom... :) PS. You machine isn't applying labels or a coating to a bottle or can is it?

i have got every thing how to connect and code is fine i just want to know how to reset arduino using the proximity sensor pnp

i just want to know how to reset arduino using the proximity sensor pnp

You don’t reset the Arduino.

You read the sensor in a holding while loop if you want to wait until it reaches a certain condition. Then when that condition is met the while loop exits and the code goes round the loop function again.

i want to deactivate the electromagnet using the proxmity sensor but not able to do that
i have connected the scanner and it is working and if it scans the barcode the electromagnet get activated but can’t turn it off using proxmity sensor

here is the code

#define WAITLOW(pin) while (digitalRead(pin) != 0);
#define WAITHIGH(pin) while (digitalRead(pin) != 1);
//GREEN POWER YELLOW GROUND BLUE CLOCK RED DATA
int clockPin = 3;
int dataPin = 4;
static volatile uint8_t head;
#define BUFFER_SIZE 45
static volatile uint8_t buffer[BUFFER_SIZE];
unsigned long lastScan = 0;
boolean scanCorrect = true;
int scannedInt = 0;
byte keymap = {0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, ‘`’, 0,
0, 0 /Lalt/, 0 /Lshift/, 0, 0 /Lctrl/, ‘q’, ‘1’, 0,
0, 0, ‘z’, ‘s’, ‘a’, ‘w’, ‘2’, 0,
0, ‘c’, ‘x’, ‘d’, ‘e’, ‘4’, ‘3’, 0,
0, ’ ‘, ‘v’, ‘f’, ‘t’, ‘r’, ‘5’, 0,
0, ‘n’, ‘b’, ‘h’, ‘g’, ‘y’, ‘6’, 0,
0, 0, ‘m’, ‘j’, ‘u’, ‘7’, ‘8’, 0,
0, ‘,’, ‘k’, ‘i’, ‘o’, ‘0’, ‘9’, 0,
0, ‘.’, ‘/’, ‘l’, ‘;’, ‘p’, ‘-’, 0,
0, 0, ‘’’, 0, ‘[’, ‘=’, 0, 0,
0 /CapsLock/, 0 /Rshift/, 0 /Enter/, ‘]’, 0, ‘\’, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, ‘1’, 0, ‘4’, ‘7’, 0, 0, 0,
‘0’, ‘.’, ‘2’, ‘5’, ‘6’, ‘8’, 0, 0 /NumLock/,
0, ‘+’, ‘3’, ‘-’, ‘*’, ‘9’, 0, 0,
0, 0, 0, 0 };
int sensorVal;

void setup() {
pinMode(clockPin, INPUT_PULLUP);
pinMode(dataPin, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);

pinMode(12, OUTPUT);

pinMode(11, OUTPUT);
Serial.begin(9600);
Serial.println(“smart kart”);
delay(2000);
}

void loop() {

WAITLOW(clockPin);
WAITHIGH(clockPin);
unsigned char keycode = 0;
for (uint8_t i = 0; i < 8; i++) {
WAITLOW(clockPin);
keycode >>= 1;
if (digitalRead(dataPin)) {
keycode |= 0x80;
}
WAITHIGH(clockPin);
}
buffer[head++] = keycode;
WAITLOW(clockPin);
WAITHIGH(clockPin);
WAITLOW(clockPin);
WAITHIGH(clockPin);
unsigned long time = millis();
scanCorrect = true;
if (head == 5 && lastScan - time > 2000) {
scannedInt = keymap[buffer[3]] - ‘0’;
if (scannedInt > 0) {
Serial.println();
Serial.println(scannedInt);
digitalWrite(11, HIGH);

Proxmity();
} else {
scanCorrect = false;
}

head = 0;
lastScan = time;
for (int i = 0; i < 5; i++) buffer = 0;

  • }*
    }
    void Proxmity() {
  • sensorVal = digitalRead(2);*
  • if (sensorVal == HIGH) {*
  • digitalWrite(12, LOW);*
    }
  • }*

akash614: i have got every thing how to connect and code is fine i just want to know how to reset arduino using the proximity sensor pnp

Proper capitalising and using punctuation goes a long way in making other people understand what you're talking about. Assuming you can write C++, you must know about those parts as they're quite essential. Please apply it to your English. The edits by other contributors (isn't it wonderful how much effort people put in trying to understand you?) go a long way but I for one am still quite at a loss of what you really want.

Schematics, code (between code tags), and an explanation of what's really going on would be helpful. Photos may also be useful.

Your code doesn’t compile:

Arduino: 1.8.1 (Linux), Board: "Arduino Pro or Pro Mini, ATmega328P (5V, 16 MHz)"

sketch_sep23a.ino: In function 'void loop()':
sketch_sep23a:78: error: incompatible types in assignment of 'int' to 'volatile uint8_t [45] {aka volatile unsigned char [45]}'
     for (int i = 0; i < 5; i++) buffer = 0;
                                        ^
exit status 1
incompatible types in assignment of 'int' to 'volatile uint8_t [45] {aka volatile unsigned char [45]}'

actually this is not the code the thing i want is to use a rs232 scanner with this and i will use max232 to convert the voltage levels and can you keep the code of the idea i want the scanner i am using is a ps2 keyboard port scanner and that is the reason i have that code will help me with code for rs232 scanner and activating and deactivating the electromagnet using scanned barcode and proximity sensor please help i will be getting the rs232 scanner in few days

actually this is not the code

Why are you wasting everyone's time?

no i am not this is a project i have to do this

akash614: no i am not this is a project i have to do this

To my mind, posting code which someone then tries to check, only to find it won't compile and then you say "but that's not the code", is wasting other peoples' time. You have every right to waste your own, of course.

That also explains why I didn't see references to a bar code scanner, an electro magnet, or a proximity sensor, but didn't look too hard as the basic sanity checks failed.

So I suggest the following to you: 1) take a course on proper writing and communication, 2) start working on your project, and if you finished 1) and get started with 2) and still have problems you post back.

Good luck.

i am saying that code is for p/s2 keyboard port i want one for rs232 port

So are we to assume you didn’t write that code and you want us to convert it for you?

here is the code i wrote yesterday can you say if it right or wrong
#include <SoftwareSerial.h>

SoftwareSerial barcode = SoftwareSerial(10, 8, true);
int sensorVal;

void setup()
{
Serial.begin(9600);
Serial.println(“Barcode Scanner Test!”);
pinMode(2, INPUT_PULLUP);

pinMode(11, OUTPUT);
// Open the SoftwareSerial port of the barcode scanner
barcode.begin(9600);

delay(1000);
}

void loop()
{
sensorVal = digitalRead(2);

if(barcode.available())
{
Serial.println(“Read”);
char data = barcode.read();
Serial.write(data);
if (sensorVal == HIGH) { digitalWrite(11, LOW);

}
else ( sensorVal = LOW); {digitalWrite(11, HIGH);
}
}
}

akash614: here is the code i wrote yesterday can you say if it right or wrong

I can try if it compiles - check if it's syntactic correct - but I assume you did that already. You can try to run the software on you hardware and see whether it does what you want. If it does, it's right. If not, you may post back with an exact description of what it does, what it doesn't, and what you think it should do.