A INTERFACE OF SENDING AND RECIVING DATA

can you all suggest me with connecting a relay to proxmity sensor the 5v dc relay

Hi,

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

You need to post you code properly to prevent formatting errors.

Tom.. :slight_smile:

I Made this new code and when the proxmitiy sensor is activated the led is not turning off which is in place of electromagnet
please help me out with this

#include <SoftwareSerial.h>

SoftwareSerial barcode = SoftwareSerial(10, 8, true); 
int sensorVal;
float metal;
int reading;
int metalPin = 3;
void setup()
{  
 Serial.begin(9600);
 Serial.println("Barcode Scanner Test!");

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

void loop()
{reading = analogRead(metalPin);
metal = (float)reading*100/1024.0;

 if(barcode.available())
 {
   Serial.println("Read");
   char data = barcode.read();
   Serial.write(data);

if(reading>250){    
digitalWrite(11, LOW);
}
else{
 digitalWrite(11,HIGH);
 }
 }
}

PLEASE READ POST #21

and do what it says....

please help me out with this

Not until you do your part of the bargain and cooperate with us.

Hi,
PLEASE, get your code in Forum format...

#include <SoftwareSerial.h>

SoftwareSerial barcode = SoftwareSerial(10, 8, true);
int sensorVal;
float metal;
int reading;
int metalPin = 3;
void setup()
{  
  Serial.begin(9600);
  Serial.println("Barcode Scanner Test!");

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

void loop()
{reading = analogRead(metalPin);
metal = (float)reading*100/1024.0;

  if(barcode.available())
  {
    Serial.println("Read");
    char data = barcode.read();
    Serial.write(data);

if(reading>250){  
digitalWrite(11, LOW);
}
else{
  digitalWrite(11,HIGH);
  }
  }
}

Tom... :slight_smile:

hello so sorry for what happened but i am not able to compile this code to my atmega32 using arduino ide and arduino i have compiled many other but not this please help me out with this
the error i am getting is

exit status 1
Error compiling for board ATmega32-16MHz.

akash614:
exit status 1
Error compiling for board ATmega32-16MHz.

That's not the full error: the error pane in the ide has a scroll bar, and/or you can drag the line between the errors and the code up to enlarge it, then post the whole error.

Hi,

It compiles for a UNO.

Exactly what Arduino controller/board are you using?

A picture of your project will help.

Thanks ... Tom.... :slight_smile:

In file included from C:\Documents and Settings\USER\Desktop\GATES_CODE_OPERATING\GATES_CODE_OPERATING.ino:1:0:

C:\Program Files\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src/SoftwareSerial.h:32:0: error: unterminated #ifndef

#ifndef SoftwareSerial_h

^

Using library SoftwareSerial at version 1.0 in folder: C:\Program Files\Arduino\hardware\arduino\avr\libraries\SoftwareSerial
exit status 1
Error compiling for board ATmega32-16MHz.

akash614:
unterminated #ifndef

#ifndef SoftwareSerial_h

^

So it tells you what's wrong there.

It needs a #endif, see here.

Hi,
What version IDE are you using?

It compiled for me as UNO, on IDE 1.8.3

Tom... :slight_smile:

i am using arduino ide ver 1.8.4

and i am trying to compile the code for atmega32 using arduino as isp then i get this message

i reinstalled arduino as it was not compiling and this message i get

C:\Program Files\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src\SoftwareSerial.cpp: In member function 'void SoftwareSerial::begin(long int)':

C:\Program Files\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src\SoftwareSerial.cpp:319:36: error: 'digitalPinToPCICR' was not declared in this scope

if (digitalPinToPCICR(_receivePin)) {

^

In file included from c:\program files\arduino\hardware\tools\avr\avr\include\avr\io.h:99:0,

from c:\program files\arduino\hardware\tools\avr\avr\include\avr\interrupt.h:38,

from C:\Program Files\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src\SoftwareSerial.cpp:41:

C:\Program Files\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src\SoftwareSerial.cpp:360:76: error: 'digitalPinToPCICRbit' was not declared in this scope

*digitalPinToPCICR(_receivePin) |= _BV(digitalPinToPCICRbit(_receivePin));

^

C:\Program Files\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src\SoftwareSerial.cpp:363:51: error: 'digitalPinToPCMSK' was not declared in this scope

_pcint_maskreg = digitalPinToPCMSK(_receivePin);

^

In file included from c:\program files\arduino\hardware\tools\avr\avr\include\avr\io.h:99:0,

from c:\program files\arduino\hardware\tools\avr\avr\include\avr\interrupt.h:38,

from C:\Program Files\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src\SoftwareSerial.cpp:41:

C:\Program Files\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src\SoftwareSerial.cpp:364:60: error: 'digitalPinToPCMSKbit' was not declared in this scope

_pcint_maskvalue = _BV(digitalPinToPCMSKbit(_receivePin));

^

Using library SoftwareSerial at version 1.0 in folder: C:\Program Files\Arduino\hardware\arduino\avr\libraries\SoftwareSerial
exit status 1
Error compiling for board ATmega32-16MHz.