Mekatronik Mühendisliği Forum


Ardunio İle Dokunmaya Duyarlı Esnek Robotik Deri
Değerlendir:
  • 0 Oy - 0 Yüzde
  • 1
  • 2
  • 3
  • 4
  • 5


Konu: 56
Mesaj: 64
Cinsiyet: Erkek
Kıdem: Sep 2014

Malzemeler

[Resim: KeyPadMatrix_Materials-300x180.jpg]

Ardunio Shematic

[Resim: MatrixKeyPad-300x245.jpg]
Kodu

*/
//include the library
#include <eRCaGuy_analogReadXXbit.h>

//instantiate an object of this library class; call it "adc"
eRCaGuy_analogReadXXbit adc;

//Global constants
//const uint8_t pin = A0; //analogRead pin
//const uint8_t pin = A1; //analogRead pin
//const uint8_t pin = A2; //analogRead pin
//const uint8_t pin = A3; //analogRead pin
//const uint8_t pin = A4; //analogRead pin
//const uint8_t pin = A5; //analogRead pin
//constants required to determine the voltage at the pin;
//BE SURE YOU USE THE CORRECT ONE OF THESE WHEN CALCULATING THE VOLTAGE FROM A READING! Take notes of how these constants are used below.
const float MAX_READING_10_bit = 1023.0;
const float MAX_READING_11_bit = 2046.0;
const float MAX_READING_12_bit = 4092.0;
const float MAX_READING_13_bit = 8184.0;
const float MAX_READING_14_bit = 16368.0;
const float MAX_READING_15_bit = 32736.0;
const float MAX_READING_16_bit = 65472.0;

// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(57600);
//pin definitions
pinMode(A0,INPUT);
pinMode(A1,INPUT);
pinMode(A2,INPUT);
pinMode(A3,INPUT);
pinMode(A4,INPUT);
pinMode(A5,INPUT);
pinMode(A6,INPUT);
pinMode(A7,INPUT);
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
//digitalWrite(2,HIGH);
//digitalWrite(3,HIGH);
//digitalWrite(4,HIGH);
//digitalWrite(5,HIGH);
//digitalWrite(6,HIGH);
//digitalWrite(7,HIGH);
//digitalWrite(8,HIGH);
//digitalWrite(9,HIGH);
}

// the loop routine runs over and over again forever:
void loop() {
//Local variables
unsigned long num_samples=10;
uint8_t bits_of_precision=12; //bits of precision for the ADC (Analog to Digital Converter)
//float analog_reading; //the ADC reading
float V; //Voltage calculated on the analog pin

// read the input on analog pins
float sensorValue0 = adc.analogReadXXbit(A0,bits_of_precision,num_samples);
float sensorValue1 = adc.analogReadXXbit(A1,bits_of_precision,num_samples);
float sensorValue2 = adc.analogReadXXbit(A2,bits_of_precision,num_samples);
float sensorValue3 = adc.analogReadXXbit(A3,bits_of_precision,num_samples);
float sensorValue4 = adc.analogReadXXbit(A4,bits_of_precision,num_samples);
float sensorValue5 = adc.analogReadXXbit(A5,bits_of_precision,num_samples);
float sensorValue6 = adc.analogReadXXbit(A4,bits_of_precision,num_samples);
float sensorValue7 = adc.analogReadXXbit(A5,bits_of_precision,num_samples);
// print out the values you read as CSV

Serial.print(sensorValue0);
Serial.print(',');
Serial.print(sensorValue1);
Serial.print(',');
Serial.print(sensorValue2);
Serial.print(',');
Serial.print(sensorValue3);
Serial.print(',');
Serial.print(sensorValue4);
Serial.print(',');
Serial.print(sensorValue5);
Serial.print(',');
Serial.print(sensorValue6);
Serial.print(',');
Serial.print(sensorValue7);
Serial.println();
delay(100); // delay in between reads for stability
}
Celal Bayar Üniversitesi-Mekatronik Mühendisliği

Cevapla
Teşekkür Edenler
.


Foruma atla:


Konuyu görüntüleyenler: 1 Misafir

Türkçe Çeviri : MyBB Türkiye
MyBB, © 2002-2018 MyBB Group.