Raspberry Pi

Raspberry Pi The raspberry pi is a series of small single-board computers developed in the United Kingdom by the Raspberry Pi Foundation to promote teaching of basic computer science in schools and in developing countries. Setting up Raspberry Pi As standard the Raspberry Pi comes without an operating system. It depends on the user which operating system is installed within the computer. The operating system can be installed on the Raspberry Pi using the following steps: ...

December 19, 2023 · 6 min · 1131 words · Aum Pauskar

Modulated motor control with arduino

Motor Encoder Components Arduino Uno 4x4 Keypad I2C LCD DC Motor with encoder L293D Motor Driver Connections Display connections From (I2C display) To (arduino) 1 VCC 5V 2 GND GND 3 SDA SDA 4 SCL SCL Keypad connections From (Keypad) To (arduino) 1 Row 1 D13 2 Row 2 D12 3 Row 3 D11 4 Row 4 D10 5 Col 1 D9 6 Col 2 D8 7 Col 3 D7 8 Col 4 D4 Motor connections From (Motor) To 1 Motor negative Output 4 (L293D) 2 Motor positive Output 3 (L293D) 3 Encoder ground GND (L293D) 4 Channel B D3 (arduino) 5 Channel A D2 (arduino) 6 Encoder power 5V (arduino) L293D connections From (L293D) To (arduino) 1 Power 1 5V 2 Input 4 D5 3 Output 4 refer above 4 Ground GND (both arduino/motor) 5 Ground GND (both arduino/motor) 6 Output 3 refer above 7 Input 3 D6 8 Enable 3,4 5V 9 Enable 1,2 5V 10 Input 1 N/A 11 Output 1 N/A 12 Ground GND 13 Ground GND 14 Output 2 N/A 15 Input 2 N/A 16 Power 2 5V Code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 // ---------- // keypad setup #include <Keypad.h> const byte numRows= 4; //number of rows on the keypad const byte numCols= 4; //number of columns on the keypad // global keypad variables String enteredValue = ""; int encoderSpeed = 0; float debugEncoderSpeed = 0.00; // (encoderSpeed * 100) / 255 //keymap defines the key pressed according to the row and columns just as appears on the keypad char keymap[numRows][numCols]= { {'1', '2', '3', 'A'}, {'4', '5', '6', 'B'}, {'7', '8', '9', 'C'}, {'*', '0', '#', 'D'} }; //Code that shows the the keypad connections to the arduino terminals byte rowPins[numRows] = {13,12,11,10}; //Rows 0 to 3 byte colPins[numCols]= {9,8,7,4}; //Columns 0 to 3 Keypad myKeypad= Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols); // ---------- // lcd setup #include <Adafruit_LiquidCrystal.h> Adafruit_LiquidCrystal lcd_1(0); int LCDRow = 0; #define motorA 5 #define motorB 6 int encoderPin1 = 2; int encoderPin2 = 3; volatile int lastEncoded = 0; volatile long encoderValue = 0; volatile long correctEncoderValue =0; long lastencoderValue = 0; int lastMSB = 0; int lastLSB = 0; void setup() { Serial.begin (9600); pinMode(encoderPin1, INPUT); pinMode(encoderPin2, INPUT); digitalWrite(encoderPin1, HIGH); //turn pullup resistor on digitalWrite(encoderPin2, HIGH); //turn pullup resistor on attachInterrupt(0, updateEncoder, CHANGE); attachInterrupt(1, updateEncoder, CHANGE); pinMode(motorA,OUTPUT); pinMode(motorB,OUTPUT); lcd_1.begin(16, 2); lcd_1.print("Enter value:"); lcd_1.setCursor(LCDRow, 10); } void loop() { // encoder control statements correctEncoderValue = encoderValue/4; Serial.println(correctEncoderValue); if ( 0<=correctEncoderValue && correctEncoderValue < 3000) { analogWrite(motorA,encoderSpeed); digitalWrite(motorB,LOW); } else { analogWrite(motorA,0); digitalWrite(motorB,LOW); } delay(100); // keypad control statements char keypressed = myKeypad.getKey(); if (keypressed != NO_KEY) { Serial.println(keypressed); } // getting the key pressed from the user if (keypressed){ // gets triggered for numeric key presses if (keypressed != 'D' && keypressed != 'A' && keypressed != 'B' && keypressed != 'C') { Serial.println(keypressed); lcd_1.print(keypressed); lcd_1.setCursor(++LCDRow, 10); enteredValue += keypressed; // a - clear the entered value } else if (keypressed == 'A') { lcd_1.clear(); lcd_1.print("Enter value:"); lcd_1.setCursor(++LCDRow, 10); enteredValue = ""; encoderSpeed = 0; // d - update the entered value } else { LCDRow = 0; lcd_1.clear(); lcd_1.print("Value updated"); delay(500); // taking the encoder speed from the user // encoder value lies between 0 and 255 // we take the value only if its between 0 and 255 if (enteredValue == "") { encoderSpeed = 0; Serial.println("Case 1: Blank entered value"); } else if (enteredValue.toInt() > 0 && enteredValue.toInt() < 255) { encoderSpeed = enteredValue.toInt(); Serial.println("Case 2: Accepted entered value"); } else { encoderSpeed = 0; Serial.println("Case 3: Out of of bounds entered value"); } } // special keypresses end } // keypressed trigger end debugEncoderSpeed = (encoderSpeed * 100) / 255; Serial.println(debugEncoderSpeed); } void updateEncoder(){ int MSB = digitalRead(encoderPin1); //MSB = most significant bit int LSB = digitalRead(encoderPin2); //LSB = least significant bit int encoded = (MSB << 1) |LSB; //converting the 2 pin value to single number int sum = (lastEncoded << 2) | encoded; //adding it to the previous encoded value if(sum == 0b1101 || sum == 0b0100 || sum == 0b0010 || sum == 0b1011) encoderValue ++; if(sum == 0b1110 || sum == 0b0111 || sum == 0b0001 || sum == 0b1000) encoderValue --; lastEncoded = encoded; //store this value for next time } How to use this Click the link below and press simulate. You can see the debug output in the serial monitor. To enter a value press a key on the keypad. To update the value press D and to clear the value press A. ...

November 21, 2023 · 5 min · 902 words · Aum Pauskar

Working with ARM microcontroller using Keil uVision4

ARM Basics Advanced RISC Machine (ARM) is a family of reduced instruction set computing (RISC) architectures for computer processors, configured for various environments. Arm Holdings develops the architecture and licenses it to other companies, who design their own products that implement one of those architectures‍—‌including systems-on-chips (SoC) and systems-on-modules (SoM) that incorporate memory, interfaces, radios, etc. It also designs cores that implement this instruction set and licenses these designs to a number of companies that incorporate those core designs into their own products. Running ARM IC within simulator Download and install Keil uVision - MDK ARM Go to project in the menu bar anc click on new uVision Project. Select lpc2148 in the menu and click it. Disable startup file. Save the project in a new folder named something. This folder name can be changed accordingly but all the dependency file should correspnd to it. Within this folder create a newfile called as something.s. Copy and paste this code in something.s 1 2 3 4 5 6 7 8 AREA ONE, CODE, READONLY ENTRY MOV R0, #0X01 MOV R1, #0X02 ADD R2, R1, R0 L B L END Click one the source group on the left hand side and right click to add existing files… Add the something.s file, by checking the assembly files option Click translate first on the menu bar and then click build the second time. Now in the menu bar click on debug and then click start/stop debug session You can click run to run everything or click on step to run one line at a time More info about the lpc2148 The microcontroller lpc 2148 is a 32 bit memory controller. ...

November 20, 2023 · 15 min · 3006 words · Aum Pauskar

Using i386 IC using Keil uVision5 and Embedded C

Embedded C Embedded C is used in embedded systems and iot deviced such as Arduino and mico IC’s. To emulate this we can use Keil, however this can be only run on Windows, to run this on linux based distros use wine. Procedure to run The following are the steps to run a code on Keil Note: Here we are working on intel 8051AH microcontroller Install and run keil If you are on a windows system you can run the exe file locally, if you are on a linux machine you can run keil through wine and it will function just like you are running it on windows natively. \ Open a new microvision project under the projects tab. Open projects first which is located in the menu bar. Click on open a new micro vision (uVision) project. \ Locate and save the folder in the desired place (with no extension). The prompt will ask you for a cocation where the project needs to be saved. It is always a great practice to always have a new project under a new folder, this makes sure that the project files remain persistant even after making modifications or making a completely new project. \ Create a new file with the extension .c and save the file. Afte completing all the steps given above, open a new wile by using ctrl+n and saving it first with the extension .c, use ctrl+s to save the file. \ Open the startup file on the left hand side and select the add file option. Select the .c file you have created. In order to execute the code that you have written, the software must include it in the environment. To do this first on the left system tray right click and then select add existing files to group and then double select your code base file. \ Translate the file first and then build the file, both the options are available on the menubar. Translating the file changes the embedded c code to assembly level code, then build it to futher convert it into binary code. Select the debug option. In the menubar select debug, the the debug menu select start/stop debug session. This will lead you upto a debug screen. In the debug screen you have to go to the run to run the code normally, or if you have to run/debug it line by line then go to the step button to run/debug it step by step. Under the peripherals tab select the peripherals you require. Unlike other languages keil, the console does not support normal IO. You have to select a peripheral to go along with it. Gain output The output can be traced by the peripheral pins to gain any digital form of output or use analysis window to analyse the function in the analog fasion. Tasks Day 1 Briefing, difference between microprocessor and microcontroller. ...

November 16, 2023 · 4 min · 803 words · Aum Pauskar

Arduino control with peripherals

Arduino 14 IO, 6// ESP 8266 wifi Sketch - name of the program Setup - IO setup Loop - while loop DHT 11 sol moisture SR04 ultrasonic HC05 bluetooth ESP 01 wifi Q. LED blink 1 2 3 4 5 6 7 8 9 10 11 const int ledVar = 13; void setup() { pinMode(ledVar, OUTPUT); } void loop() { digitalWrite(ledVar, HIGH); delay(1000); digitalWrite(ledVar, LOW); delay(1000); } Q. Interface dht 11 with arduino uno and display humidity and temperature on serial monitor 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #include <dht.h> dht DHT; #define dhtPin 4 void setup() { Serial.begin(9600); } void loop() { // put your main code here, to run repeatedly: int val = DHT.read11(dhtPin); Serial.print("Temprature: "); Serial.println(DHT.temperature); Serial.print("Humidity: "); Serial.println(DHT.humidity); delay(2000); } If else 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 // Q. Interface dht 11 with arduino uno and display humidity and temperature on serial monitor #include <dht.h> dht DHT; #define dhtPin 4 const int ledVar = 13; void setup() { Serial.begin(9600); pinMode(ledVar, OUTPUT); } void loop() { // put your main code here, to run repeatedly: int val = DHT.read11(dhtPin); Serial.print("Temprature: "); // float temp = DHT.temperature; if ( DHT.temperature > 25.00) { digitalWrite(ledVar, HIGH); } else { digitalWrite(ledVar, LOW); } Serial.println(DHT.temperature); Serial.print("Humidity: "); Serial.println(DHT.humidity); delay(2000); } Button operation 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 const char led1 = A5; const char led2 = A4; const char led3 = A3; const char led4 = A2; const int b1 = 13; const int b2 = 12; const int b3 = 11; const int b4 = 10; int buttonState1, buttonState2, buttonState3, buttonState4; void setup() { // put your setup code here, to run once: pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); pinMode(led3, OUTPUT); pinMode(led4, OUTPUT); pinMode(b1, INPUT); pinMode(b2, INPUT); pinMode(b3, INPUT); pinMode(b4, INPUT); Serial.begin(9600); } void loop() { // put your main code here, to run repeatedl if (digitalRead(b1) == LOW) { digitalWrite(led1, HIGH); digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, LOW); } else if (digitalRead(b2) == LOW){ digitalWrite(led1, LOW); digitalWrite(led2, HIGH); digitalWrite(led3, LOW); digitalWrite(led4, LOW); } else if (digitalRead(b3) == LOW){ digitalWrite(led1, LOW); digitalWrite(led2, LOW); digitalWrite(led3, HIGH); digitalWrite(led4, LOW); } else if (digitalRead(b4) == LOW){ digitalWrite(led1, LOW); digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, HIGH); } else { digitalWrite(led1, LOW); digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, LOW); } } LCD 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #include <LiquidCrystal.h> const int rs = 6, en = 7, d4 = 5, d5 = 4, d6 = 3, d7 = 2; LiquidCrystal lcd(rs, en, d4, d5, d6, d7); void setup() { lcd.begin(16,2); lcd.print(" Hello "); lcd.setCursor(0,1); lcd.print(" World "); } void loop() { // put your main code here, to run repeatedly: lcd.noDisplay(); lcd.display(); delay(5000); } IoT internship project 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 /*Problem statement Interface LCD with Arduino Uno to display the right to left scrolling message IoT Internship */ // title, problem statement, onjective, components, interfacing block diagram // libraries #include <LiquidCrystal.h> // programming constants const int rs = 6, en = 7, d4 = 5, d5 = 4, d6 = 3, d7 = 2; LiquidCrystal lcd(rs, en, d4, d5, d6, d7); int initialDelay = 1000; int pixelDelay = 300; char message[] = "IoT Internship"; void setup() { lcd.begin(16, 2); lcd.print(message); delay(initialDelay); } void loop() { // given count values to properly scroll through the screen for (int positionCounter = 0; positionCounter < 13; positionCounter++) { lcd.scrollDisplayLeft(); delay(pixelDelay); } for (int positionCounter = 0; positionCounter < 29; positionCounter++) { lcd.scrollDisplayRight(); delay(pixelDelay); } for (int positionCounter = 0; positionCounter < 16; positionCounter++) { lcd.scrollDisplayLeft(); delay(pixelDelay); } delay(1000); }

November 16, 2023 · 4 min · 707 words · Aum Pauskar