Posts

Showing posts from November, 2018

BMP180 Code + Library to SD card

#include <Wire.h> #include <SD.h> #include "BMP180Lib.c" #define BMP180_ADDRESS 0x77 // I2C address of BMP180 // Read 1 byte from the BMP180 at 'address' // Add these to the top of your program const float p0 = 101325; // Pressure at sea level (Pa) float altitude; const int CS_PIN =10; char bmp180Read(unsigned char address) {  unsigned char data;  Wire.beginTransmission(BMP180_ADDRESS);  Wire.write(address);  Wire.endTransmission();  Wire.requestFrom(BMP180_ADDRESS, 1);  while(!Wire.available())  ;  return Wire.read(); } // Read 2 bytes from the BMP180 // First byte will be from 'address' // Second byte will be from 'address'+1 int bmp180ReadInt(unsigned char address) {  unsigned char msb, lsb;  Wire.beginTransmission(BMP180_ADDRESS);  Wire.write(address);  Wire.endTransmission();  Wire.requestFrom(BMP180_ADDRESS, 2);  while(Wire.available()<2)  ;  msb = Wire....

Strings

#include <stdio.h> #include <string.h> int main(void) { /* Declare and initialize variables. */ int count=0; int choice = 0; int l_l, l_s; char long_str[80]; char short_str[79]; char *ptr1=long_str, *ptr2=short_str; while (choice != 1 && choice != 2){ printf( "1. read from file \n OR 2. input longstring "); scanf(" %i", &choice); } printf(" \n"); if( choice == 1) { FILE *file; file = fopen("longstring.txt", "r"); if(file){ fgets(long_str, 80, file); } fclose(file); } if (choice == 2){ printf("Print the long string: \t"); scanf("%s", &long_str); } printf("Print short string: \t"); scanf("%s", &short_str); l_l = strlen(long_str); l_s = strlen(short_str); printf("Original Long String: "); for (int i =0;i<=l_l; i++){ printf("%c", long_str[i]); if(((int)long_str[i]) < 97){ long_str[i] = (cha...