Shinichiro Nakamura
/
TouchSenseTestProgram
A capacitive touch sensor using a analog input port.
main.cpp@0:56ef498b597d, 2013-08-14 (annotated)
- Committer:
- shintamainjp
- Date:
- Wed Aug 14 09:11:26 2013 +0000
- Revision:
- 0:56ef498b597d
The first version of the sample.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shintamainjp | 0:56ef498b597d | 1 | /* mbed Microcontroller Sample Program |
shintamainjp | 0:56ef498b597d | 2 | * Copyright (c) 2013 Shinichiro Nakamura |
shintamainjp | 0:56ef498b597d | 3 | * |
shintamainjp | 0:56ef498b597d | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
shintamainjp | 0:56ef498b597d | 5 | * you may not use this file except in compliance with the License. |
shintamainjp | 0:56ef498b597d | 6 | * You may obtain a copy of the License at |
shintamainjp | 0:56ef498b597d | 7 | * |
shintamainjp | 0:56ef498b597d | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
shintamainjp | 0:56ef498b597d | 9 | * |
shintamainjp | 0:56ef498b597d | 10 | * Unless required by applicable law or agreed to in writing, software |
shintamainjp | 0:56ef498b597d | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
shintamainjp | 0:56ef498b597d | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
shintamainjp | 0:56ef498b597d | 13 | * See the License for the specific language governing permissions and |
shintamainjp | 0:56ef498b597d | 14 | * limitations under the License. |
shintamainjp | 0:56ef498b597d | 15 | */ |
shintamainjp | 0:56ef498b597d | 16 | #include "mbed.h" |
shintamainjp | 0:56ef498b597d | 17 | #include "TouchSense.h" |
shintamainjp | 0:56ef498b597d | 18 | |
shintamainjp | 0:56ef498b597d | 19 | TouchSense ts1(p15); |
shintamainjp | 0:56ef498b597d | 20 | TouchSense ts2(p16); |
shintamainjp | 0:56ef498b597d | 21 | TouchSense ts3(p17); |
shintamainjp | 0:56ef498b597d | 22 | TouchSense ts4(p18); |
shintamainjp | 0:56ef498b597d | 23 | TouchSense ts5(p19); |
shintamainjp | 0:56ef498b597d | 24 | TouchSense ts6(p20); |
shintamainjp | 0:56ef498b597d | 25 | |
shintamainjp | 0:56ef498b597d | 26 | int main() { |
shintamainjp | 0:56ef498b597d | 27 | ts1.calibration(); |
shintamainjp | 0:56ef498b597d | 28 | ts2.calibration(); |
shintamainjp | 0:56ef498b597d | 29 | ts3.calibration(); |
shintamainjp | 0:56ef498b597d | 30 | ts4.calibration(); |
shintamainjp | 0:56ef498b597d | 31 | ts5.calibration(); |
shintamainjp | 0:56ef498b597d | 32 | ts6.calibration(); |
shintamainjp | 0:56ef498b597d | 33 | while (true) { |
shintamainjp | 0:56ef498b597d | 34 | printf("[%c%c%c%c%c%c]\r\n", |
shintamainjp | 0:56ef498b597d | 35 | ts1.sense() ? 'o' : '.', |
shintamainjp | 0:56ef498b597d | 36 | ts2.sense() ? 'o' : '.', |
shintamainjp | 0:56ef498b597d | 37 | ts3.sense() ? 'o' : '.', |
shintamainjp | 0:56ef498b597d | 38 | ts4.sense() ? 'o' : '.', |
shintamainjp | 0:56ef498b597d | 39 | ts5.sense() ? 'o' : '.', |
shintamainjp | 0:56ef498b597d | 40 | ts6.sense() ? 'o' : '.'); |
shintamainjp | 0:56ef498b597d | 41 | wait(0.050); |
shintamainjp | 0:56ef498b597d | 42 | } |
shintamainjp | 0:56ef498b597d | 43 | } |