in that example he used pull up, the input received voltage from VCc, which make it 1,once the button pressed the input will become 0,that is why our boss instruct the machine that if(port of the input ==0),the port set to be output should be on.
]]>(LED) = (~LED);
__delay_ms(100);
Above tutorial is not working properly. I was not able to control LED by switch , LED is glowing like blinking. can you please write the code for that?
]]>please sir tell me.
]]>Better try some other PORTS. For PORTA you need to configure it as digital input first.
Don’t forget to configure TRIS register for setting whether a pin is Input/Output.
]]>sbit LCD_RS_Direction at TRISC7_bit;
sbit LCD_EN_Direction at TRISD4_bit;
sbit LCD_D4_Direction at TRISD5_bit;
sbit LCD_D5_Direction at TRISD6_bit;
sbit LCD_D6_Direction at TRISD7_bit;
sbit LCD_D7_Direction at TRISB3_bit;
char txt[9]; // declare a char array
char txt2[11]; // declare a char array
void main(){
TRISA.RA1=1; // PORTA is input
TRISA.RA2=1; // PORTA is input
TRISA.RA3=1;
TRISB=0; // PORTC is Output
TRISC=0; // PORTC is Output
ADC_Init(); // Initialize ADC module with default settings
Lcd_Init(); // Initialize Lcd
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,7,”Welcome”); // dsiaplay the welcome logo on the LCD screen at position ROW=1 COLUMN=1
delay_ms(100); // keep displaying logo for 5s
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,3,”Adam Ubaid”);
delay_ms(100); // keep displaying logo for 5s
while(1){
inputread = ADC_Read(1);
inputread2 = ADC_Read(2);// Read analog value from channel 0
delay_ms(5);
inputmeasured=(inputread*4.88)/1000; // converting to value
in = (inputmeasured/0.005);
inputmeasured2=(inputread2*4.88)/1000; // converting to value
in2 = (inputmeasured2/50000.0);
floatToStr(in,txt);
floatToStr(in2,txt2);
Lcd_Out(3,1,”PV Volts”);
lcd_out(3,12,txt);
Lcd_Out(4,1,”OUTPUT V “);
lcd_out(4,12,txt2);
if(PORTA.RA3 == 1) //If the switch is pressed
{
Lcd_Out(2,1,”OVERLOAD “);
}
} }
#include
#include
#include “trial.h”
#include
void main(void) {
TRISB = 0b00000000;
while(1){
PORTBbits.RB3 = 1;
}
}
But nothing is happening. I’m using mplab with pickit 3, everything seems to be fine, the code compiles and gets downloaded to the pic but not working.
Help! Thanks!
I would like to use your example on a machine. It works like this:
1. I have to push 2 buttons together to get an input to the micro controller
2. Air cylinder 1 must move for a set time and then stop.
3 Air cylinder 2 must move for a set time and then stop.
4. Air cylinder 1 must continue.
5. Air cylinder 3 must move for a set time and then stop.
6. Air cylinder 1 must return to home position.
Am I able to do this or is there a better way?
thankyou in advance
John