We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]
posted on 2016/10/05 05:25:55 PM CEST
GAS DETECTECTION CODE USING PIC 16F877A AND LCD AND BUZZER WHEN THERE IS A LEAKAGE
posted on 2016/10/03 12:31:20 PM CEST
pls send me the interfacing of temperature and humidity sensor with PIC18F4550 and display on LCD.
posted on 2016/09/06 09:02:26 AM CEST
I would like to have a code that can run 2 hall current clicks at the same time on the same board and be able to display it on the 2x16 LCD. Below is the code I have written but have been stuck since. Please correct or guide me into the right coding.
//Lcd module connections
sbit LCD_RS at LATB4_bit;
sbit LCD_EN at LATB5_bit;
sbit LCD_D4 at LATB0_bit;
sbit LCD_D5 at LATB1_bit;
sbit LCD_D6 at LATB2_bit;
sbit LCD_D7 at LATB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
sbit Chip_Select at RE0_bit;
sbit Chip_Select_Direction at TRISE0_bit;
sbit Chip_Select1 at RA5_bit;
sbit Chip_Select1_Direction at TRISA5_bit;
char txt[15], txt1[15];
int current_read, current_read1, i, value;
float current_read_float, current_read1_float;
// Get current value from 1
unsigned Hall_Read() {
// Local variable
unsigned int tmp = 0, tmp0 = 0, tmp1 = 0;
unsigned int buffer = 0;
Chip_Select = 0; // Select MCP3201
tmp0 = SPI1_Read(buffer); // Get value
tmp1 = SPI1_Read(buffer); // Get value
Chip_Select = 1; // Deselect MCP3201
tmp = ((tmp1) | (tmp0 << 8));
return tmp; // Returns value
}
// Get current value
unsigned Hall_Read1() {
// Local variable
unsigned int tmpA = 0, tmp0A = 0, tmp1A = 0;
unsigned int buffer = 0;
Chip_Select1 = 0; // Select MCP3201
tmp0A = SPI1_Read(buffer); // Get value
tmp1A = SPI1_Read(buffer); // Get value
Chip_Select1 = 1; // Deselect MCP3201
tmpA = ((tmp1A) | (tmp0A << 8));
return tmpA; // Returns value
}
void main() {
ANSELC = 0;
ANSELE = 0;
ANSELA = 0;
// Set chip select pin to be output
Chip_Select_Direction = 0;
Chip_Select = 1;
// Set chip select pin to be output
Chip_Select1_Direction = 0;
Chip_Select1 = 1;
// Initialize SPI1 module
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV16, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_HIGH_2_LOW);
Delay_ms(100);
// LCD Init
LCD_Init();
LCD_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
// Display string on the LCD
Lcd_Out(1,1,"Current [A1&A2]:");
while(1) {
// Read current from Hall Click
current_read = Hall_Read();
// If Sensor Current Value Transmission
if ((current_read >> 15) == 0) {
current_read = current_read & 0x1FFF; // Get [13:0] bits of current value
current_read = current_read - 4096; // Map the current value
current_read_float = (float)current_read * 0.0125; // Calculate the current value in Amperes
FloatToStr(current_read_float,txt); // Convert the current value to a string
sprintf(txt, "%2.1f", current_read_float); // Trim the string from leading spaces
// Display the current value
Lcd_Out(2,1,"I1:");
Lcd_Out(2,4,txt);
}
/*current_read1= Hall_Read1();
if ((current_read1 >> 15) == 0) {
current_read1 = current_read1 & 0x1FFF; // Get [13:0] bits of current value
current_read1 = current_read1 - 4096; // Map the current value
current_read1_float = (float)current_read1 * 0.0125; // Calculate the current value in Amperes
FloatToStr(current_read1_float,txt1); // Convert the current value to a string
sprintf(txt1, "%2.1f", current_read1_float); // Trim the string from leading spaces
// Display the current value
Lcd_Out(2,9,"I2:");
Lcd_Out(2,12,txt1);
}*/
delay_ms(2000);
}
}
posted on 2016/09/06 08:24:22 AM CEST
I want to read a string of hex data from UART an save data to another string as don't destroy my data or overwright.
posted on 2016/09/02 04:30:24 PM CEST
for a project I'm doing with mikroPascal 32 you need a library that can handle a USB hub with keyb hid and hid scanner, if someone has done could buy
Thank you