Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MFS_Display_HAL_401
main.cpp
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2019 ARM Limited 00003 * SPDX-License-Identifier: Apache-2.0 00004 */ 00005 00006 #include "mbed.h" 00007 #include "platform/mbed_thread.h" 00008 #include "MFS.h" 00009 00010 // Blinking rate in milliseconds 00011 #define BLINKING_RATE_MS 500 00012 00013 MFS mfs; 00014 Ticker meinTicker; 00015 Ticker MotorTicker; 00016 int analog; 00017 char seg7[10]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F}; 00018 00019 00020 DigitalOut summer(PB_3); 00021 00022 char schritt[4]={0b0011,0b0110,0b1100,0b1001}; 00023 00024 PortOut Motor(PortC,0xF); 00025 00026 int digit=0x10; 00027 int pos=0; 00028 00029 void drehen() 00030 { 00031 Motor=schritt[pos]; 00032 pos=(pos+1)%4; 00033 } 00034 00035 00036 void anzeigen() 00037 { 00038 int ausgabe=analog; 00039 00040 switch(digit) 00041 { 00042 case 0x10: mfs=(digit<<8)+seg7[ausgabe%10]; 00043 digit=0x20; 00044 break; 00045 case 0x20: mfs=(digit<<8)+seg7[(ausgabe/10)%10]; 00046 digit=0x40; 00047 break; 00048 case 0x40: mfs=(digit<<8)+seg7[(ausgabe/100)%10]; 00049 digit=0x80; 00050 break; 00051 case 0x80: mfs=(digit<<8)+seg7[(ausgabe/1000)%10]; 00052 digit=0x10; 00053 break; 00054 00055 } 00056 //mfs=0x80FC; 00057 } 00058 00059 int main() 00060 { 00061 // Initialise the digital pin LED1 as an output 00062 DigitalOut led(LED1); 00063 AnalogIn Poti(PA_0); 00064 meinTicker.attach_us(&anzeigen,1000); 00065 MotorTicker.attach_us(&drehen,10000); 00066 summer=1; 00067 while (true) { 00068 led = !led; 00069 thread_sleep_for(BLINKING_RATE_MS); 00070 analog=Poti*9999; 00071 if (analog<1000) summer=0; 00072 else summer=1; 00073 MotorTicker.attach_us(&drehen,analog*2); 00074 } 00075 }
Generated on Sat Aug 6 2022 12:50:16 by
1.7.2