This document contains programs for a PIC microcontroller that implement various functions including:
1) Scanning a 4x4 keypad and displaying the pressed number on a 7-segment display.
2) Using an ADC to read pressure sensor data and transmit it via RS-232.
3) Transmitting and receiving data between two PICs via RS-232.
4) Blinking LEDs on ports and driving a buzzer.
5) Reading an ADC and displaying the value on an LCD.
6) Implementing a timer and counting seconds on an LCD.
7) Using I2C to communicate with a device.
8) Scanning a keypad and unlock
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdffootstatus
How do I draw the Labview code for pneumatic cylinder(air pistion). (Start with banana-plug>>
Pneumatic cylinder(air pistion) moves back and forward certain times or certain seconds>> end)
Solution
#include
#include
#include
#include
#include \"RTClib.h\"
#define LOG_INTERVAL 1 // milsec betweens entries
#define SYNC_INTERVAL 100
uint32_t syncTime =0;
RTC_DS1307 RTC; // Real Time Clock
// On the Ethernet Shield, CS is pin 4. Note that even if it\'s not
// used as the CS pin, the hardware CS pin (10 on most Arduino boards,
// 53 on the Mega) must be left as an output or the SD library
// functions will not work.
const int chipSelect = 10;
//switch inputs and variables
const int kPinReedSwitch1 = 22;
const int kPinReedSwitch2 = 24;
const int relayPin = 26;
int strokedown = 0;
int inc = 0;
int precountA =0;
int precountB = 0;
int count = 0;
int runcycles = 20;
int reset = 0;
int initial = 1;
int start =1;
int LinearPot1Pin = A0; // select the input pin for the potentiometer
float sensorValue = 0.0; // variable to store the value coming from the sensor
int MC_travel = 0;
int on =0;
//logging file
File logfile;
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
void error(char *str)
{
Serial.print(\"error: \");
Serial.println(str);
while(1);
}
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// Input pins for Arduino
pinMode(kPinReedSwitch1, INPUT_PULLUP);
pinMode(kPinReedSwitch2, INPUT_PULLUP);
pinMode(relayPin, OUTPUT);
Serial.print(\"Initializing SD card...\");
// make sure that the default chip select pin is set to
// output, even if you don\'t use it:
pinMode(53, OUTPUT);
// see if the card is present and can be initialized:
if (!SD.begin(10,11,12,13)) {
Serial.println(\"Card failed, or not present\");
// don\'t do anything more:
return;
}
Serial.println(\"card initialized.\");
// creating a new file for data logger
char filename[] = \"LOGGER00.CSV\";
for (uint8_t i = 0; i < 100; i++){
filename[6] = i/10 + \'0\';
filename[7] = i%10 + \'0\';
if(! SD.exists(filename)){
logfile = SD.open(filename, FILE_WRITE);
break;
}
}
if (!logfile) {
error(\"couldnt create file\");
}
Serial.print(\"Logging to:\");
Serial.println(filename);
logfile.println(\"MC Travel\");
// LCD initialization
lcd.begin(20,4);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(\"Count: \");
lcd.setCursor(0,1);
lcd.print(\"MC Travel: in\");
}
void loop()
{
for(int i = 1; i < 2; i++ )
//an initialization routine just to get cylinder to \"home\"
//although should never really be away from home
{
digitalWrite(relayPin, HIGH);
delay(200);
digitalWrite(relayPin, LOW);
delay (2000);
}
while( count <= runcycles){
if( start ==1 && digitalRead(kPinReedSwitch1)==HIGH){
digitalWrite(relayPin, HIGH);
}
else if (digitalRead(kPinReedSwitch1) == LOW)
// turns on relay when reed switch A is triggered
// Logic reversed because of pullup resistors
{
strokedown = 1;
precountA =1;
start=0;// .
What will be quantization step size in numbers and in voltage for th.pdfSIGMATAX1
What will be quantization step size in numbers and in voltage for this Arduino Code? Using 5V
const int led1 = 2;
const int led2 = 3;
const int led3 = 4;
void setup() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
int dataConv = sensorValue*(8.0/1024);
//write analog equvivalant data on led pins
switch(dataConv)
{
case 0: {
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
break;
}
case 1: {
digitalWrite(led1,HIGH);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
break;
}
case 2: {
digitalWrite(led1,LOW);
digitalWrite(led2,HIGH);
digitalWrite(led3,LOW);
break;
}
case 3: {
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led3,LOW);
break;
}
case 4: {
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,HIGH);
break;
}
case 5: {
digitalWrite(led1,HIGH);
digitalWrite(led2,LOW);
digitalWrite(led3,HIGH);
break;
}
case 6: {
digitalWrite(led1,LOW);
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
break;
}
case 7: {
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
break;
}
}
Serial.println(sensorValue); // print out the value you read:
Serial.println(dataConv);
delay(1000); // delay in between reads for stability
}
const int led1 = 2;
const int led2 = 3;
const int led3 = 4;
void setup() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
int dataConv = sensorValue*(8.0/1024);
//write analog equvivalant data on led pins
switch(dataConv)
{
case 0: {
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
break;
}
case 1: {
digitalWrite(led1,HIGH);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
break;
}
case 2: {
digitalWrite(led1,LOW);
digitalWrite(led2,HIGH);
digitalWrite(led3,LOW);
break;
}
case 3: {
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led3,LOW);
break;
}
case 4: {
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,HIGH);
break;
}
case 5: {
digitalWrite(led1,HIGH);
digitalWrite(led2,LOW);
digitalWrite(led3,HIGH);
break;
}
case 6: {
digitalWrite(led1,LOW);
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
break;
}
case 7: {
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
break;
}
}
Serial.println(sensorValue); // print out the value you read:
Serial.println(dataConv);
delay(1000); // delay in between reads for stability
}
Solution
// Random LED Dots - from noise source
// Ed Nisley - KE4ANU - September 2015
//----------
// Pin assignments
const byte PIN_HEARTBEAT = 8; // DO - heartbeat LED
const byte PIN_SYNC = A3; // DO.
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdffootstatus
How do I draw the Labview code for pneumatic cylinder(air pistion). (Start with banana-plug>>
Pneumatic cylinder(air pistion) moves back and forward certain times or certain seconds>> end)
Solution
#include
#include
#include
#include
#include \"RTClib.h\"
#define LOG_INTERVAL 1 // milsec betweens entries
#define SYNC_INTERVAL 100
uint32_t syncTime =0;
RTC_DS1307 RTC; // Real Time Clock
// On the Ethernet Shield, CS is pin 4. Note that even if it\'s not
// used as the CS pin, the hardware CS pin (10 on most Arduino boards,
// 53 on the Mega) must be left as an output or the SD library
// functions will not work.
const int chipSelect = 10;
//switch inputs and variables
const int kPinReedSwitch1 = 22;
const int kPinReedSwitch2 = 24;
const int relayPin = 26;
int strokedown = 0;
int inc = 0;
int precountA =0;
int precountB = 0;
int count = 0;
int runcycles = 20;
int reset = 0;
int initial = 1;
int start =1;
int LinearPot1Pin = A0; // select the input pin for the potentiometer
float sensorValue = 0.0; // variable to store the value coming from the sensor
int MC_travel = 0;
int on =0;
//logging file
File logfile;
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
void error(char *str)
{
Serial.print(\"error: \");
Serial.println(str);
while(1);
}
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// Input pins for Arduino
pinMode(kPinReedSwitch1, INPUT_PULLUP);
pinMode(kPinReedSwitch2, INPUT_PULLUP);
pinMode(relayPin, OUTPUT);
Serial.print(\"Initializing SD card...\");
// make sure that the default chip select pin is set to
// output, even if you don\'t use it:
pinMode(53, OUTPUT);
// see if the card is present and can be initialized:
if (!SD.begin(10,11,12,13)) {
Serial.println(\"Card failed, or not present\");
// don\'t do anything more:
return;
}
Serial.println(\"card initialized.\");
// creating a new file for data logger
char filename[] = \"LOGGER00.CSV\";
for (uint8_t i = 0; i < 100; i++){
filename[6] = i/10 + \'0\';
filename[7] = i%10 + \'0\';
if(! SD.exists(filename)){
logfile = SD.open(filename, FILE_WRITE);
break;
}
}
if (!logfile) {
error(\"couldnt create file\");
}
Serial.print(\"Logging to:\");
Serial.println(filename);
logfile.println(\"MC Travel\");
// LCD initialization
lcd.begin(20,4);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(\"Count: \");
lcd.setCursor(0,1);
lcd.print(\"MC Travel: in\");
}
void loop()
{
for(int i = 1; i < 2; i++ )
//an initialization routine just to get cylinder to \"home\"
//although should never really be away from home
{
digitalWrite(relayPin, HIGH);
delay(200);
digitalWrite(relayPin, LOW);
delay (2000);
}
while( count <= runcycles){
if( start ==1 && digitalRead(kPinReedSwitch1)==HIGH){
digitalWrite(relayPin, HIGH);
}
else if (digitalRead(kPinReedSwitch1) == LOW)
// turns on relay when reed switch A is triggered
// Logic reversed because of pullup resistors
{
strokedown = 1;
precountA =1;
start=0;// .
What will be quantization step size in numbers and in voltage for th.pdfSIGMATAX1
What will be quantization step size in numbers and in voltage for this Arduino Code? Using 5V
const int led1 = 2;
const int led2 = 3;
const int led3 = 4;
void setup() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
int dataConv = sensorValue*(8.0/1024);
//write analog equvivalant data on led pins
switch(dataConv)
{
case 0: {
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
break;
}
case 1: {
digitalWrite(led1,HIGH);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
break;
}
case 2: {
digitalWrite(led1,LOW);
digitalWrite(led2,HIGH);
digitalWrite(led3,LOW);
break;
}
case 3: {
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led3,LOW);
break;
}
case 4: {
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,HIGH);
break;
}
case 5: {
digitalWrite(led1,HIGH);
digitalWrite(led2,LOW);
digitalWrite(led3,HIGH);
break;
}
case 6: {
digitalWrite(led1,LOW);
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
break;
}
case 7: {
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
break;
}
}
Serial.println(sensorValue); // print out the value you read:
Serial.println(dataConv);
delay(1000); // delay in between reads for stability
}
const int led1 = 2;
const int led2 = 3;
const int led3 = 4;
void setup() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
int dataConv = sensorValue*(8.0/1024);
//write analog equvivalant data on led pins
switch(dataConv)
{
case 0: {
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
break;
}
case 1: {
digitalWrite(led1,HIGH);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
break;
}
case 2: {
digitalWrite(led1,LOW);
digitalWrite(led2,HIGH);
digitalWrite(led3,LOW);
break;
}
case 3: {
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led3,LOW);
break;
}
case 4: {
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,HIGH);
break;
}
case 5: {
digitalWrite(led1,HIGH);
digitalWrite(led2,LOW);
digitalWrite(led3,HIGH);
break;
}
case 6: {
digitalWrite(led1,LOW);
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
break;
}
case 7: {
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
break;
}
}
Serial.println(sensorValue); // print out the value you read:
Serial.println(dataConv);
delay(1000); // delay in between reads for stability
}
Solution
// Random LED Dots - from noise source
// Ed Nisley - KE4ANU - September 2015
//----------
// Pin assignments
const byte PIN_HEARTBEAT = 8; // DO - heartbeat LED
const byte PIN_SYNC = A3; // DO.
Cosmetic shop management system project report.pdfKamal Acharya
Buying new cosmetic products is difficult. It can even be scary for those who have sensitive skin and are prone to skin trouble. The information needed to alleviate this problem is on the back of each product, but it's thought to interpret those ingredient lists unless you have a background in chemistry.
Instead of buying and hoping for the best, we can use data science to help us predict which products may be good fits for us. It includes various function programs to do the above mentioned tasks.
Data file handling has been effectively used in the program.
The automated cosmetic shop management system should deal with the automation of general workflow and administration process of the shop. The main processes of the system focus on customer's request where the system is able to search the most appropriate products and deliver it to the customers. It should help the employees to quickly identify the list of cosmetic product that have reached the minimum quantity and also keep a track of expired date for each cosmetic product. It should help the employees to find the rack number in which the product is placed.It is also Faster and more efficient way.
Welcome to WIPAC Monthly the magazine brought to you by the LinkedIn Group Water Industry Process Automation & Control.
In this month's edition, along with this month's industry news to celebrate the 13 years since the group was created we have articles including
A case study of the used of Advanced Process Control at the Wastewater Treatment works at Lleida in Spain
A look back on an article on smart wastewater networks in order to see how the industry has measured up in the interim around the adoption of Digital Transformation in the Water Industry.
Immunizing Image Classifiers Against Localized Adversary Attacksgerogepatton
This paper addresses the vulnerability of deep learning models, particularly convolutional neural networks
(CNN)s, to adversarial attacks and presents a proactive training technique designed to counter them. We
introduce a novel volumization algorithm, which transforms 2D images into 3D volumetric representations.
When combined with 3D convolution and deep curriculum learning optimization (CLO), itsignificantly improves
the immunity of models against localized universal attacks by up to 40%. We evaluate our proposed approach
using contemporary CNN architectures and the modified Canadian Institute for Advanced Research (CIFAR-10
and CIFAR-100) and ImageNet Large Scale Visual Recognition Challenge (ILSVRC12) datasets, showcasing
accuracy improvements over previous techniques. The results indicate that the combination of the volumetric
input and curriculum learning holds significant promise for mitigating adversarial attacks without necessitating
adversary training.
Overview of the fundamental roles in Hydropower generation and the components involved in wider Electrical Engineering.
This paper presents the design and construction of hydroelectric dams from the hydrologist’s survey of the valley before construction, all aspects and involved disciplines, fluid dynamics, structural engineering, generation and mains frequency regulation to the very transmission of power through the network in the United Kingdom.
Author: Robbie Edward Sayers
Collaborators and co editors: Charlie Sims and Connor Healey.
(C) 2024 Robbie E. Sayers
18. #include <16f877a.h> //Libreria del PIC
#fuses HS,NOWDT //Fuses del PIC
#use delay(clock=20 MHz) //Especifica la velocidad de reloj
//Declaracion del microcontrolador
#use fast_io(B) //Prepara para el uso de puerto B
#use fast_io(C) //Prepara para el uso de puerto C
#use fast_io(D) //Prepara para el uso de puerto D
//Nombrar puertos
#bit ENTER = 0x06.0 //Nombra a un solo pin ENTER en este caso RB0
#byte FILAS = 0x07 //Nombra FILA al PORTC
#byte COLUMNAS = 0x08 //Nombra COLUMNA al PORTD
//Inicializar el PIC
void MCU_Init(){
//Entradas y Salidas
set_tris_b(0x01); //RB0 como entrada
set_tris_c(0x00); //PORTC=COLUMNAS como salidas
set_tris_d(0x00); //PORTD=FILAS como salida
//Configuraos interrupcion externa
enable_interrupts(GLOBAL); //Habilita las interrupciones
ext_int_edge(L_TO_H); //Se activa con flanco de subida
enable_interrupts(INT_EXT); //Expecifica interrupcion externa
}
void CaraEnojada(){
COLUMNAS= 0b00000001;
FILAS= 0b11000011;