Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

AT89C2051 code problem

Status
Not open for further replies.

Arrowspace

Banned
Joined
Jan 23, 2015
Messages
186
Helped
3
Reputation
6
Reaction score
3
Trophy points
18
Activity points
0
My code is not working.


Code:
//#include <REG2051.H>
//#include <REGX52.H>
//#include<reg51.h>
//#include<AT892051.H>
//#include<AT89x51.h>	

#include <reg2051.h>   

void T1M1Delay(void);
void delay(unsigned int msec ); // Time delay function


  sbit input1 = P3^2;
  sbit input2 = P3^7;
  sbit Relay = P1^0;
  sbit mosfet = P3^4;
   


void main()
{
/*
P3_2 = 1; 
P3_3 = 1; 
P1_0 = 0; 
P1_7 = 0; 
 */
 input1 = 1;
 input2 = 0;
 Relay = 0;
 mosfet = 0;
 
//delay(2);
while(1)
{
/*
T1M1Delay() ;
T1M1Delay() ;

T1M1Delay() ;
T1M1Delay() ;
T1M1Delay() ;
T1M1Delay() ;
T1M1Delay() ;
T1M1Delay() ;
*/

  input2=0;
Relay = 0;	 
mosfet = 0;
delay(2);
}
}



void delay(unsigned int msec ) // Time delay function
{
int i ,j ;
for(i=0;i<msec;i++)
  for(j=0; j<1275; j++);
}

 void T1M1Delay(void)
 {
  TMOD=0x10;
  TL1=0xFE;
  TH1=0x0A5;
  TR1=1;
  while(TF1==0);
  TR1=0;
  TF1=0;
 }



I am trying to glow LED on my board , which is not working is connected on pin P3.7
 
Last edited by a moderator:

This code below seemed to work OK. Tested with LED's on outputs. LED's on when PINs = 0;

Code:
void delay(unsigned int msec ); // Time delay function

#define input1 P3_2   //   sbit input1 = P3^2;
#define input2 P3_7   //   sbit input2 = P3^7;
#define Relay P1_0    //   sbit Relay = P1^0;
#define mosfet P3_4   //   sbit mosfet = P3^4;
   


void main()
{
   input1 = 1;     //   PORT3 PIN 2 = 1
   input2 = 0;     //   PORT3 PIN 7 = 0
   Relay  = 0;     //   PORT1 PIN 0 = 0
   mosfet = 0;     //  PORT3 PIN 4 = 0
 
   while(1)        // while forever
      {
      input2 = 0;  // keep everything the same as above
      Relay  = 0;	 
      mosfet = 0;
      delay(2);    // wait before keeping everything the same again
      }
}


void delay(unsigned int msec ) // Time delay function
{
   int i ,j ;
   for( i = 0; i < msec; i++)
      for( j = 0; j < 1275; j++);
 

this code is also not working

Pls find circuit

6524424700_1438802619[1].jpg
 

According to the schematic you've posted, it appears the value of the current limiting resistor, ~2KΩ, is too high and does not allow sufficient current to light the LED.

If your Vcc = 5V, required current I = 10mA, LED forward voltage drop Vf ~ 2V, then the current limiting resistor, R ~ 300Ω/330Ω.


BigDog
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top